forked from laarc/laarc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run.arc
executable file
·60 lines (57 loc) · 1.04 KB
/
run.arc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!bin/arc
; Run arc expressions. 1 Jan 23.
;
; Arguments are Arc expressions:
;
; $ ./run.arc 1 2
; 1
; 2
;
; $ ./run.arc '(+ "foo" "bar")'
; foobar
;
; Each value is bound to "that", letting you refer to previous vals:
;
; $ ./run.arc 1 '(+ 1 that)' '(* 2 that)'
; 1
; 2
; 4
;
; You can omit the outermost parens in each expression:
;
; $ ./run.arc 1 '+ 1 that' '* 2 that'
; 1
; 2
; 4
;
; $ ./run.arc 'range 1 10' 'apply + that'
; (1 2 3 4 5 6 7 8 9)
; 45
;
; Nil values won't be printed:
;
; $ ./run.arc 1 nil 2 ''
; 1
; 2
;
; You can call racket functions:
;
; $ ./run.arc 'string-prefix? "foo" "f"'
; #t
;
; Compile arc.arc to scheme, then open the compiled code in vim:
;
; $ ./run.arc 'let it "arc.arc" (acompile it) (filechars (+ it ".scm"))' | vim -
;
; Measure startup time:
;
; $ time ./run.arc
; ./run.arc 2.81s user 0.09s system 94% cpu 3.066 total
(def readarg (arg)
(aand (readall:cat arg)
(if (cdr it) it (car it))))
(def run args
(each arg args
(= that (eval:readarg arg))
(if that (prn that))))
run