Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(map |(+ $0 $1 ) [1 2 3 ] [4 5 6 ]) # @[5 7 9] - uses the fn shorthand (->>
(string/split " " "this is an example yes, an example" )
(filter (complement empty? ))
(frequencies ))
# -> @{"is" 1 "example" 2 "yes," 1 "an" 2 "this" 1}
# same as:
(frequencies
(filter
(complement empty? )
(string/split " " "this is an example yes, an example" )))(chr "a" ) # => 97 # repeat is about _side-effects_, since it returns nil.
# You'll need to use a mutable collection if you want to
# use repeat to add repeated items to a collection:
(var coll @["Y" "Z" ]) #=> @["Y" "Z"]
(repeat 3 (array/push coll "A" )) #=> nil
coll
# Returns:
@["Y" "Z" "A" "A" "A" ]
# You can use map if the whole collection consists
# of these repetitions:
(map (fn [_ ] "A" ) (range 3 ))
# Returns:
@["A" "A" "A" ](map boolean? [true false nil 0 1 ])
# => @[true true false false false]
(get (os/environ ) "HOME" ) # => "/Users/cell"
(os/getenv "HOME" ) # => "/Users/cell"
(print "The build hash of your Janet executable is " janet/build "." )(let [a 1 ]
(let [b a ]
b )) # => 1
(->> ["small" "cuddly" "creature" ]
(interpose "-" )
splice
keyword )
# => :small-cuddly-creature (string "hello" nil true 42 :bar ) # => "helloniltrue42bar"
(string :a :b :c ) # => "abc"
(zipcoll [:a :b :c ] [1 2 3 ]) #=> @{:c 3 :a 1 :b 2} (get default-peg-grammar :h )
# => '(range "09" "af" "AF") (get-in [[4 5 ] [6 7 ]] [0 ] 42 ) # => (4 5)
(get-in [[4 5 ] [6 7 ]] [0 1 ] 42 ) # => 5
(get-in [[4 5 ] [6 7 ]] [-1 ] 42 ) # => 42
(get-in [[4 5 ] [6 7 ]] [9 9 9 ] 42 ) # => 42
(map string/from-bytes "Hello, world!" ) # => @["H" "e" "l" "l" "o" "," " " "w" "o" "r" "l" "d" "!"] [1 2 3] # => (1 2 3)
(tuple 1 2 3) # => (1 2 3)
(tuple (splice [1 2 3]) # => (1 2 3)
(tuple ;[1 2 3]) # => (1 2 3)