Skip to content

Commit 2568664

Browse files
committed
chore: update examples to use the new syntax elements
1 parent 3177a4d commit 2568664

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(mut n 5)
22
(while (> n 1) {
3-
(print (string:format "{} Bottles of beer on the wall\n{} bottles of beer\nTake one down, pass it around" n n))
3+
(print (format "{} Bottles of beer on the wall\n{} bottles of beer\nTake one down, pass it around" n n))
44
(set n (- n 1))
5-
(print (string:format "{} Bottles of beer on the wall." n)) })
5+
(print (format "{} Bottles of beer on the wall." n)) })

webapp/public/contents/ide/ark/examples/macros.template

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
($ suffix-dup (sym x) {
1+
(macro suffix-dup (sym x) {
22
($if (> x 1) (suffix-dup sym (- x 1)))
33
($symcat sym x) })
44

5-
($ partial (func ...defargs) {
6-
($ bloc (suffix-dup a (- ($argcount func) (len defargs))))
5+
(macro partial (func ...defargs) {
6+
(macro bloc (suffix-dup a (- ($argcount func) (len defargs))))
77
(fun (bloc) (func ...defargs bloc))
88
($undef bloc) })
99

@@ -15,10 +15,10 @@
1515
(print "Expected arguments for test_func1: " ($argcount test_func1) ", expected " 2)
1616
(print "Calling them: " (test_func 1 2 3) " " (test_func1 2 3))
1717

18-
($ foo (a b) (+ a b))
18+
(macro foo (a b) (+ a b))
1919
(print "Using macro foo (a b) => (+ a b): " (foo 1 2))
2020

21-
($ var 12)
21+
(macro var 12)
2222
(print "Using macro constant var=12: " var)
2323

2424
($if (= var 12)
@@ -29,42 +29,42 @@
2929
(print "This was executed in a if macro, testing (and true true)")
3030
(print "You shouldn't see this (bis)"))
3131

32-
($ defun (name args body) (let name (fun args body)))
32+
(macro defun (name args body) (let name (fun args body)))
3333
(defun a_func (a b) (+ a b))
3434
(print "Generated a function with a macro, a_func (a b) => (+ a b)")
3535
(print "Calling (a_func 1 2): " (a_func 1 2))
3636

37-
($ one (...args) (print "Macro 'one', returns the 2nd argument given in " args " => " (@ args 1)))
37+
(macro one (...args) (print "Macro 'one', returns the 2nd argument given in " args " => " (@ args 1)))
3838
(one 1 2)
3939
(one 1 3 4)
4040
(one 1 5 6 7 8)
4141

42-
($ last (...args) (print "Macro 'last', returns the last argument given in " args " => " (@ args -1)))
42+
(macro last (...args) (print "Macro 'last', returns the last argument given in " args " => " (@ args -1)))
4343
(last 1 2)
4444
(last 1 3 4)
4545
(last 1 5 6 7 8)
4646

4747
{
4848
(print "Testing macros in scopes and macro shadowing")
4949

50-
($ test (+ 1 2 3))
50+
(macro test (+ 1 2 3))
5151
(print "(global) Reading macro 'test', expected 6, " test)
5252

5353
((fun () {
54-
($ test (- 1 2 3))
54+
(macro test (- 1 2 3))
5555
(print "(sub scope) Reading macro 'test', expected -4, " test) }))
5656

5757
(print "(global) Reading macro 'test', expected 6, " test)
5858

5959
{
60-
($ test 555)
60+
(macro test 555)
6161
(print "(subscope) Reading macro 'test', expected 555, " test)
62-
($ undef test)
62+
($undef test)
6363
(print "(subscope, undef test) Reading macro 'test', expected 6, " test)
64-
($ undef a) } }
64+
($undef a) } }
6565
(print "Demonstrating a threading macro")
6666

67-
($ -> (arg fn1 ...fn) {
67+
(macro -> (arg fn1 ...fn) {
6868
($if (> (len fn) 0)
6969
(-> (fn1 arg) ...fn)
7070
(fn1 arg)) })

webapp/public/contents/ide/ark/learning/02-function_with_return_val.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
(let num2 5)
88

99
# and use them with our adder function to get the sum
10-
(print (string:format "{} + {} = {}" num1 num2 (adder num1 num2)))
10+
(print (format "{} + {} = {}" num1 num2 (adder num1 num2)))

0 commit comments

Comments
 (0)