aboutsummaryrefslogtreecommitdiffstats
path: root/docs/reference
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2025-09-14 10:12:13 +0000
committers-ol <s+removethis@s-ol.nu>2025-09-14 15:36:21 +0000
commit06c239e4f44849a3e4c8317194caacbcc47fc2d4 (patch)
tree491c8c5f9e3ad4351aa55951a0d7c70cd8686087 /docs/reference
parentexpose Tag to Ops (diff)
downloadalive-06c239e4f44849a3e4c8317194caacbcc47fc2d4.tar.gz
alive-06c239e4f44849a3e4c8317194caacbcc47fc2d4.zip
de/fn, loop parameter lists use square brackets
Diffstat (limited to 'docs/reference')
-rw-r--r--docs/reference/03-3_functions.md8
-rw-r--r--docs/reference/03-4_dynamic-symbols.md4
-rw-r--r--docs/reference/03-5_loops.md4
-rw-r--r--docs/reference/03-6_modules-and-loading.md2
4 files changed, 8 insertions, 10 deletions
diff --git a/docs/reference/03-3_functions.md b/docs/reference/03-3_functions.md
index 6715eb7..4fc32ba 100644
--- a/docs/reference/03-3_functions.md
+++ b/docs/reference/03-3_functions.md
@@ -5,8 +5,7 @@ code, amongst other things:
(import* math)
(def add-and-trace
- (fn
- (a b)
+ (fn [a b]
(trace (+ a b))))
(add-and-trace 1 2)
@@ -29,8 +28,7 @@ example is equivalent to the following:
(import* math)
(def add-and-trace
- (fn
- (a b)
+ (fn [a b]
(trace (+ a b)))
(do
@@ -53,5 +51,5 @@ name, so there is the `defn` shorthand, which combines the `def` and `fn`
builtins into a single expression. Compare this equivalent definition of the
`add-and-trace` function:
- (defn add-and-trace (a b)
+ (defn add-and-trace [a b]
(trace (+ a b)))
diff --git a/docs/reference/03-4_dynamic-symbols.md b/docs/reference/03-4_dynamic-symbols.md
index eb12a41..fdaa1b9 100644
--- a/docs/reference/03-4_dynamic-symbols.md
+++ b/docs/reference/03-4_dynamic-symbols.md
@@ -8,7 +8,7 @@ then the surrounding scope (the whole file), where the value `"original
message"` is found:
(def hello "original message")
- (defn print-hello () (print hello))
+ (defn print-hello [] (print hello))
(do
(def hello "overwritten message")
@@ -24,7 +24,7 @@ scope that contains the *function definition*, but rather the scope containing
the *function call site*:
(def *hello* "original message")
- (defn print-hello () (print *hello*))
+ (defn print-hello [] (print *hello*))
(do
(def *hello* "overwritten message")
diff --git a/docs/reference/03-5_loops.md b/docs/reference/03-5_loops.md
index aedc4ab..d25fa03 100644
--- a/docs/reference/03-5_loops.md
+++ b/docs/reference/03-5_loops.md
@@ -6,7 +6,7 @@ begins a recursive loop, and [recur][] is used to restart it:
(import* math logic string)
- (loop (n 5)
+ (loop [n 5]
(when (!= n 0)
(print (str "hello #" n))
(recur (- n 1))))
@@ -30,7 +30,7 @@ as follows:
(import* math logic string)
- (defn loop-fn (n)
+ (defn loop-fn [n]
(when (!= n 0)
(print (str "hello #" n))
(loop-fn (- n 1))))
diff --git a/docs/reference/03-6_modules-and-loading.md b/docs/reference/03-6_modules-and-loading.md
index cb53cc1..0f28e7e 100644
--- a/docs/reference/03-6_modules-and-loading.md
+++ b/docs/reference/03-6_modules-and-loading.md
@@ -57,7 +57,7 @@ rather the newly created scope. It can therefore be combined with [def][],
(export
(def a-value 7)
- (defn print-doubled (x) (print (str x " doubled is " (* x 2)))))
+ (defn print-doubled [x] (print (str x " doubled is " (* x 2)))))
`main.alv`