We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents ac7512d + 6debb54 commit 77b7468Copy full SHA for 77b7468
examples/short-fn.janet
@@ -0,0 +1,19 @@
1
+# a function that doubles its arguments
2
+((fn [n] (+ n n)) 10) # -> 20
3
+((short-fn (+ $ $)) 10) # -> 20
4
+
5
+# pipe reader macro offers terser expression
6
+(|(+ $ $) 10) # -> 20
7
8
+# $0 is also the first (zero-th) argument
9
+(|(+ $0 $0) 10) # -> 20
10
11
+# handling multiple arguments: $0, $1, ...
12
+(|(string $0 $1) "hi" "ho") # -> "hiho"
13
14
+# variadic function
15
+(|(apply + $&) 1 2 3) # -> 6
16
17
+# structs and some other things work too
18
+(|{:a 1}) # -> {:a 1}
19
0 commit comments