Welcome, I'm happy to see you here! Feel free to pick a function and add a happy example, the more the merrier!
(map dictionary? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false false false true true ]
(map struct? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false false false true false ]
(map table? [ 'ab :ab "ab" @"ab" [97 98 ] @[97 98 ] {0 97 1 98 } @{0 97 1 98 } ])
# => @[ false false false false false false false true ] # convert a string to an integer
(peg/match '(number :d+ ) "123" )
#=> @[123]
(first (peg/match '(number :d+ ) "123" ))
#=> 123 (seq [i :range [0 3 ]
j :range [0 3 ]
:let [c (string/format "%c" (+ 97 i ))]]
[(keyword c ) j ])
# => '@[(:a 0) (:a 1) (:a 2) (:b 0) (:b 1) (:b 2) (:c 0) (:c 1) (:c 2)] (kvs (struct :a 1 :b 2 ))
# => @[:a 1 :b 2] (defn f1 [s ] (string "-" s "-" ))
(defn f2 [s ] (string "=" s "=" ))
(defn f3 [s ] (string "#" s "#" ))
(def f (juxt f1 f2 f3 ))
(f "x" ) # => ("-x-" "=x=" "#x#") (var x 1 )
(+= x 2 3 4 )
# x = 10 (print math/int-min )
-9007199254740992
nil (eval-string "(+ 1 2 3 4)" ) # -> 10
(eval-string ")" ) # -> parse error
(eval-string "(bloop)" ) # -> compile error
(eval-string "(+ nil nil)" ) # -> runtime error # more at https://github.com/sogaiu/margaret/tree/master/examples
(peg/match ~{:main (replace (some :header-line )
,(fn [& captures ]
(table ;captures )))
:header-line (sequence (capture :header-name ) ":"
:s+
(capture :header-value ) :crlf )
:header-name (to ":" )
:header-value (to :crlf )
:crlf "\r\n" }
(string "Content-Type: text/plain\r\n"
"Content-Length: 1024\r\n" ))
# => @[@{"Content-Length" "1024" "Content-Type" "text/plain"}]
(defn dataframe
``Create an empty dataframe with the given columns``
[& columns ]
(tabseq [c :in columns ] c @[]))(def h ["a" "b" :c ]) # => ("a" "b" :c)
(find (fn [a ] (= "a" a )) h ) # => "a" (update-in @{:a @{:b 1 }} [:a :b ] (fn [x ] (+ 1 x )))
# @{:a @{:b 2}}
(disasm + )
# {:max-arity 2147483647
# :constants @[]
# :name "+"
# :defs @[]
# :vararg true
# :environments @[]
# :arity 0
# :slotcount 6
# :bytecode
# @[(len 1 0)
# (eqim 2 1 0)
# (jmpno 2 3)
# (ldi 3 0)
# (ret 3)
# (eqim 2 1 1)
# (jmpno 2 5)
# (ldi 3 0)
# (geti 4 0 0)
# (add 3 3 4)
# (ret 3)
# (geti 3 0 0)
# (ldi 5 1)
# (in 4 0 5)
# (add 3 3 4)
# (addim 5 5 1)
# (eq 2 5 1)
# (jmpno 2 -4)
# (ret 3)]
# :min-arity 0}
(fiber? (fiber/new (fn [])))
# => true
(var buf @"" )
(buffer/push-word buf 2147483647 )
(+
(get buf 0 ) # byte 1
(blshift (get buf 1 ) 8 ) # byte 2
(blshift (get buf 2 ) 16 ) # byte 3
(blshift (get buf 3 ) 24 )) # byte 4
# => 2147483647