-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.ss
48 lines (45 loc) · 1.76 KB
/
demo.ss
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
(unless (assoc "." (library-directories))
(library-directories (cons "." (library-directories))))
(print-gensym #f)
(load "build.ss")
(import (juniper))
;;; Demonstrates calling J addons from scheme
(define (demo-e/p)
(define J (start-j))
(j-e/p J "'called in directory, ',1!:43''")
(j-e/p J "load 'stats/bonsai'")
(j-e/p J "bonsai '+/ 1 + i. 1000000'")
(j-e/p J "some_not_defined_name")
(j-e/p J "fibo =: ([: +/ [: $:\"0 (_1 _2)&+)`]@.(<&2)")
(j-e/p J "echo fibo\"0 i. 10")
(j-e/p J "mfib =: ([: +/ [: $:\"0 (_1 _2)&+)`]@.(<&2) M.")
(j-e/p J "(;: 'expr time') , (,. (6!:2 &.>)) 'fibo 25';'mfib 25';'mfib 500' ; 'mfib 500'")
(j-e/p J "5!:4 < 'mfib'")
(j-exit J (current-output-port)))
;;; Demonstrates setting variables in J from scheme and grabbing them
;;; inside scheme
(define (demo-value)
(define J (start-j))
(j-e/p J "'integer';iv=: i. 3 4")
(j-e/p J "'string';sv=: 'cat'")
(j-e/p J "'bools';bv=: 1 p: iv")
(j-e/p J "'floats';dv=: ?. 3 2 2 $ 0")
(j-e/p J "'complex';zv=: j.\"0/~ i. 4")
(j-e/p J "'boxes1';bxv1=: (2 3 $ 0.1 0.3);'mouse';_900;'J';(,:_800);<\"_1 i. 3 2 3 2")
(j-e/p J "'boxes2';bxv2=: <\"0 i. 3 3")
(j-e/p J "'boxes3';bxv3=: ;: 'cat in a hat'")
(j-e/p J "'extended';ev=: x: 9000 * i. 12")
(j-e/p J "'extended2';ev2=: ! 100x")
(j-e/p J "'rational';rv=: 3 2 $ 3r2 7r5 9r2 11r6")
(display (j-get J "iv")) (newline)
(display (j-get J "sv")) (newline)
(display (j-get J "bv")) (newline)
(display (j-get J "dv")) (newline)
(display (j-get J "zv")) (newline)
(display (j-get J "ev")) (newline)
(display (j-get J "ev2")) (newline)
(display (j-get J "rv")) (newline)
(display (j-get J "bxv1")) (newline)
(display (j-get J "bxv2")) (newline)
(display (j-get J "bxv3")) (newline)
(exit-j J (current-output-port)))