Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 25 20:19
    pixelherodev edited #1047
  • Nov 25 20:17
    pixelherodev opened #1047
  • Nov 21 05:00
    dressupgeekout opened #1046
  • Nov 15 03:27
    Pebaz closed #1044
  • Nov 15 03:27
    Pebaz commented #1044
  • Nov 14 08:04
    sogaiu commented #1044
  • Nov 14 02:09
    sogaiu commented #1044
  • Nov 13 20:57
    Pebaz edited #1044
  • Nov 13 20:56
    Pebaz opened #1044
  • Nov 11 17:48

    bakpakin on master

    Update state header to include … (compare)

  • Nov 11 17:25

    bakpakin on master

    Simplify eval. Also add more c… (compare)

  • Nov 11 17:15

    bakpakin on master

    Simplify eval-string implementa… (compare)

  • Nov 11 17:02

    bakpakin on master

    Create pthread threads with det… (compare)

  • Nov 10 22:57
    bakpakin opened #1043
  • Nov 10 22:54
    bakpakin closed #1042
  • Nov 10 22:32

    bakpakin on master

    Add channel marshalling. (compare)

  • Nov 09 15:35
    autumnull commented #1042
  • Nov 09 14:47
    bakpakin closed #1041
  • Nov 09 14:47
    bakpakin commented #1041
  • Nov 09 14:19
    pepe commented #1042
Bryan Maass
@escherize
I'll try building on this machine
thanks @bakpakin:matrix.org
bakpakin
@bakpakin:matrix.org
[m]
Both <janet.h> and <janet/janet.h> should work for includes with jpm
Also use jpm show-paths and look for headerpath
andrewchambers
@andrewchambers
whats the reason for the new symlink?
bakpakin
@bakpakin:matrix.org
[m]
The convention of #include <janet.h> only worked with jpm by default - without any specially flags (compiling with cc mymod.c) the include declaration would be #include <janet/janet.h>
So in the latest installer I set it up to add a symlink so that janet.h was installed to both /usr/include/janet/janet.h and /usr/include/janet.h
basically, my editor was getting confused by the includes. Someone a while ago made a patch or an issue to move janet.h to janet/janet.h and I foolishly merged it
but I think there might be some issues with the meson version since I bet homebrew has an old meson version (just a guess)
andrewchambers
@andrewchambers
hmm, ok - dunno if I've seen other packages do that - install the same header into two places
bakpakin
@bakpakin:matrix.org
[m]
Yeah, it honestly shouldn't affect this at all though, it should just add a symlink so not sure why it would be unable to find janet.h
actually, just checking and I see a few packages that do this
andrewchambers
@andrewchambers
:P
bakpakin
@bakpakin:matrix.org
[m]
my ncurses install seems to lol, not exactly a great justification
libpng, and a few smaller ones.
StayingAlive1998
@StayingAlive1998
image.png
I found getline in the docs and setq in a CLisp tutorial and removed the q because it didnt highlight. How can i change a variable based on terminal input?
bakpakin
@bakpakin:matrix.org
[m]

I would be careful with a Common Lisp tutorial, Janet is not common lisp.

Your issue is that you need to declare a binding first with def. For example, (def name (getline)) will store a buffer in a binding name.

Please read the Janet documentation for examples
StayingAlive1998
@StayingAlive1998
I am reading them. I was vaguely on that path but it felt like a stretch. Thank you! will read up on those concepts!
StayingAlive1998
@StayingAlive1998
mind blown its all starting to make sense. This is such a clean and well documented language!
John Gabriele
@uvtc
@StayingAlive1998 , I wrote up some Janet "quick ref" notes that I think are pretty useful as well: http://www.unexpected-vortices.com/janet/notes-and-examples/language-basics.html
StayingAlive1998
@StayingAlive1998
Great! The more resources the merrier. I especially like a title you gave in the functions category "Lazy Seqs" haha. Thank you Mr.Gabriel.
John Gabriele
@uvtc
You're welcome. It's still pretty incomplete, but I update it every now and again.
Jeanne-Kamikaze
@jeannekamikaze
Hello guys. What happened to file/popen? Is there an equivalent under a different name now?
Looks like I may need os/spawn.
Jeanne-Kamikaze
@jeannekamikaze

Ok, RTFM.

./CHANGELOG.md:- Remove file/popen. Use os/spawn with the :pipe options instead.

StayingAlive1998
@StayingAlive1998

Ive spent many hours trying to figure this out so i feel comfortable asking. How do i write: if x in array1 ... to replace the messes ive created. Ive thought of having one array with all variations of yes and no and if x is in the 0-4 slot in the array than do so and so else if x is in 5-9 slot do so and so. Ive thought of makeing two tuples and placing them in slot 0 and 1 in an array respectively and if the tuple containing a match to x is in array slot 0 do this else do that.
Ultimately id like: if x in dataset check dataset2 if x in dataset 2 do this if not check if x in dataset3 if x in dataset3 do this if x not in dataset restart

if x in dataset
check dataset2
if true
do this
if x not in dataset
do this #there are only 2 datasets. 1 for yes's and 1 for no's
if x not in dataset
prompt user for input again

although ive been trying to figure this out for a total of about 16 hours i find it interesting...

image.png
StayingAlive1998
@StayingAlive1998
in the real world im trying to write a Do you want to play the game y/n prompt that accepts Y YES Yes yes and y and same for no
bakpakin
@bakpakin:matrix.org
[m]
A few things will help you here - first might be wrapping the part you ask the user a question and get a response into a function, say 'ask-question'. This would be a good chance to learn how to use defn.
That sort of "if ladder" pattern can be done with exactly that, a ladder of ifs.
(if condition-1
  do-thing-a
  (if condition-2
    do-thing-b
    (if condition-3
      ...))))
there is a macro to make this easier though - cond
(cond
  condition-1 do-thing-a
  condition-2 do-thing-b
  condition-3 do-thing-c)
bakpakin
@bakpakin:matrix.org
[m]
Second, the logic you want to do is a good use-case for tables or struct. You can "map" an input string to a boolean value to convert it to - for example, the string "Y" should map to true, so should "yes", but "N" and "no" should map to false.
In the spirit of learning I suppose I should leave the rest for you to figure out

An example of a struct as I mentioned above:

(def mapping-struct
  {"Yes" true
    "y" true
    "No" false
    "n" false
     ... # add more here
    })

There are various improvements to this scheme, such as making input case-insensitive, handling bad inputs by asking again, etc.

StayingAlive1998
@StayingAlive1998
image.png
@bakpakin:matrix.org ballin'
StayingAlive1998
@StayingAlive1998
image.png
1 reply
not ballin'
bakpakin
@bakpakin:matrix.org
[m]
Some small style things - "nil" is not the same as nil, use nil for a number of reasons. Next, you should probably make your question function return the answer rather than set a var.
Next suggestion, make another function ask-yn-question to ask a question, and then return a boolean that would be true if the user answers "Yes", "y", etc. This will let you do things like:
(if (ask-yn-question "Proceed into castle?")
   (print "Onward!")
   (print "Thou art a coward!"))
bakpakin
@bakpakin:matrix.org
[m]
A small hint on making the ask-yn-question:
(defn ask-yn-question
   [question]
   (print question)
   # remove the trailing newline
   (def answer (string/trimr (getline)))
   (def boolean (get y-n-struct answer))
   boolean)
The last expression in a function is what the expression "returns" or evaluates to, so the ask-yn-question evaluates to true or false depending on the input (or nil if the use enters some garbage input)
xoich
@xoich
hello! I get an error with jpm install:
$ export JANET_PATH=$HOME/janet
$ jpm install https://github.com/swlkr/janet-html
error: Permission denied: /usr/lib64/janet/.cache
3 replies
pp
@damnpepe:matrix.org
[m]
Oh sorry, that is true.
I missed the first line.
xoich
@xoich
no problem, janet -v is 1.22.0-meson