Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(var a false )
(defer (set a 42 )
(set a true )
(error "Oh no!" ))
# error: Oh no!
(pp a ) # => prints 42 (map bytes? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ true true true true false false false false ]
(map symbol? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ true false false false false false false false ]
(map keyword? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false true false false false false false false ]
(map string? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false true false false false false false ]
(map buffer? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false true false false false false ] # From: https://codeberg.org/veqq/janetdocs/src/commit/54a964d1a35920af2655c4932a9b51379e8b9380/helpers.janet#L52
(defn current-account [request ]
(def login (get-in request [:session :login ] "" ))
(joy/db/find-by :account :where {:login login }))(blshift 8 2 ) # => 32 (eachk k [1 2 3 ] (print k ))
# prints 0
# prints 1
# prints 2
# for indexed collections indices are printed (eachp [k v ] {:a "a val" :b "b val" :c "c val" } (print k " - " v ))
# prints c - c val
# prints a - a val
# prints b - b val janet:2:> (all true? [true true false ])
false
janet:3:> (all even? [2 4 6 7 ])
false
janet:5:> (all even? [2 4 6 ])
true (drop 1 [1 1 2 3 5 8 ])
# => '(1 2 3 5 8) # sh/$ can't expand "~" so you must build it:
# (def key "D8E4DB18BF87FLEW7402BBE3AA91B16F4A65C4C9") # use your gpg key ID
(defn copy-and-encrypt-password-store [key-id ]
(with [out (file/open "pass-backup.tar.gz.gpg" :w )]
(sh/$ tar -czf - ,(string (os/getenv "HOME" ) "/.password-store" )
| gpg --encrypt --recipient ,key-id > ,out )))
# tar -cz ~/.password-store/ | gpg --encrypt --recipient YOUR_KEY_ID > pass-backup.tar.gz.gpg # absolute value of negatives, ignore positives
(keep |(if (< $ 0 ) (- $ ) nil ) [-1 2 -3 -4 -5 6 ]) # -> @[1 3 4 5]
# halves each even number, ignores odds
(keep |(when (even? $ ) (/ $ 2 )) [1 2 8 7 -2 ]) # -> @[1 4 -1]
(do
(var a 88 )
(+= a 12 )) # 100
(slice [:a :b :c :d ]) # => (:a :b :c :d)
(slice [:a :b :c :d ] 0 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] 1 ) # => (:b :c :d)
(slice [:a :b :c :d ] 3 ) # => (:d)
(slice [:a :b :c :d ] 4 ) # => ()
(slice [:a :b :c :d ] 5 ) # error: index out of range
(slice [:a :b :c :d ] -1 ) # => ()
(slice [:a :b :c :d ] -2 ) # => (:d)
(slice [:a :b :c :d ] -4 ) # => (:b :c :d)
(slice [:a :b :c :d ] -5 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] -6 ) # error: index out of range
(slice [:a :b :c :d ] 0 0 ) # => ()
(slice [:a :b :c :d ] 0 1 ) # => (:a)
(slice [:a :b :c :d ] 0 4 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] -1 -1 ) # => ()
(slice [:a :b :c :d ] -2 -1 ) # => (:d)
(slice [:a :b :c :d ] -5 -1 ) # => (:a :b :c :d)
(slice [:a :b :c :d ] 1 0 ) # => ()
(slice [:a :b :c :d ] 4 0 ) # => ()
(slice [:a :b :c :d ] -1 -2 ) # => ()
(slice [:a :b :c :d ] -1 -5 ) # => ()
(string/bytes "foo" ) # => (102 111 111)
(string/from-bytes 102 111 111 ) # => "foo"
(string/from-bytes (splice (string/bytes "foo" ))) # => "foo"
(map (fn [x ] x ) "foo" ) # => @[102 111 111]
(map string/from-bytes "foo" ) # => @["f" "o" "o"]
(defn string/explode [s ] (map string/from-bytes s ))
(string/explode "foo" ) # => @["f" "o" "o"]
(/ 1 2 3 )
# => 0.166667
(extreme < [1 2 3 ]) # => 1
(extreme > [1 2 3 ]) # => 3