bakpakin on localbindings
Update symbolmapping code with … (compare)
bakpakin on localbindings
initial slotsyms implementation symbolslots now use janet_v vec… symbolslots nil when there are … and 7 more (compare)
bakpakin on master
Fix null check. (compare)
bakpakin on master
Fix issue with environments in … (compare)
Ok, RTFM.
./CHANGELOG.md:- Remove file/popen
. Use os/spawn
with the :pipe
options instead.
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...
(if condition-1
do-thing-a
(if condition-2
do-thing-b
(if condition-3
...))))
cond
(cond
condition-1 do-thing-a
condition-2 do-thing-b
condition-3 do-thing-c)
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.
"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.
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!"))
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)
ask-yn-question
evaluates to true or false depending on the input (or nil if the use enters some garbage input)
I think I'm having a bit of an issue putting modules and macros together. The simplest form of this problem seems to be:
Define a module X with:
The symbol "foo" works inside the module, and therefore from baz.
However, if another module Y imports X and uses the macro X/bar, then "foo" becomes an unknown symbol, should be "X/foo" instead. Except that "X/foo" doesn't seem to work inside the X module (macro bar, function baz).
(defn my-fn [x] (+ x x))
(defn my-mac [y] ~(,my-fn (,inc ,y)))
(my-mac 1) # evaluates to 4, and avoids hygiene problem
@xoich: it could be that using both JANET_PATH
and JANET_MODPATH
might help for your case.
JANET_PATH
has to do with where to look for janet libraries while JANET_MODPATH
has to do with where jpm installs libarries to.
iirc, the jpm man page has more details.