matchyet, btw. I like it, but it does make the macro its signature less descriptive in this case. 🤔
(defmacro ifte [if-cond then-kw then-exp else-kw else-exp] (match @[if-cond then-kw then-exp else-kw else-exp] @[if-cond :then then-exp :else else-exp] ~(if ,if-cond ,then-exp ,else-exp) (error "Expected (ifte <if> :then <then> :else <else>"))
> janet -e '(empty? 1)' in empty? [boot.janet] on line 121, column 50 in _thunk [eval-string] (tailcall) on line 1, column 1 in eval1 [boot.janet] on line 2333, column 16 in run-context [boot.janet] on line 2393, column 13 in eval-string [boot.janet] on line 2432, column 3 in e-switch [boot.janet] (tailcall) on line 3618, column 12 in cli-main [boot.janet] on line 3644, column 13
Is it by design? Or is it error on my side?
(defmacro vars [& bindings] ~(upscope ,;(seq [[n v] :in (partition 2 bindings)] (tuple 'var n v)))) (defmacro defs [& bindings] ~(upscope ,;(seq [[n v] :in (partition 2 bindings)] (tuple 'def n v))))
How would one increase the value of a field in a 3-dimensional array by one (like the ++ macro does) the janet way?
To give an example I want to increase the 1 to a 2:
@( @( @(0 0 0) @(0 1 0) @(0 0 0)) @( @(0 0 0) @(0 0 0) @(0 0 0)) )
(get-in wait, you're using@(
putand alike for associative datastructures and set for vars
(++ (variant-amount-of-gets-here))would have worked
(defmacro ++in [variable arr] ~(,put-in ,variable ,arr (+ (,get-in ,variable ,arr) 1)))
update-inis probably the best way to do what you want using standard pieces
(string/from-bytes 2r01111111 ;(seq [i :down-to [56 0 8]] (scan-number (string (band (brshift (int/u64 dl) i) 0x000000FF)))))