annotate stringjs.rhope @ 189:d0e3a13c1bd9 default tip

Remove old calculator example
author Mike Pavone <pavone@retrodev.com>
date Fri, 07 Oct 2011 00:24:04 -0700
parents fc3815b7462f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 Blueprint String
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
5 Buffer
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
7
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
8 Foreign Javascript:builtin
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
9 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
10 print[val]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 parseInt[string,base(Int32,Naked):out(Int32,Naked)]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
12 _internal_js_eq[left,right:out(Boolean,Naked)]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 slice@[string,start(Int32,Naked),end(Int32,Naked):out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 concat@[left,right:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 Print@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 print[[string]Buffer >>]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 out <- Yes
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 Int32@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 out <- parseInt[[string]Buffer >>, 10]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
27
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28 Hex Int32[str:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30 out <- parseInt[[str]Buffer >>, 16]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
31 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 Flatten@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35 out <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
36 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 Slice@String[string,slicepoint:left,right]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 If[[slicepoint]>=[[string]Length]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
41 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
42 left <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 right <- ""
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 If[[slicepoint]<=[0]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 left <- ""
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
48 right <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
49 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
50 [string]Buffer >>
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
51 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
52 left <- [Build[String()]]Buffer <<[[~]slice[0,slicepoint]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
53 right <- [Build[String()]]Buffer <<[[~]slice[slicepoint,_internal_js_length[~]]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
54 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
55 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
56 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 /*
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 Byte@String[string,index:out,invalid]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
61 out,invalid <- [[string]Buffer >>]Index[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
62 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
63 */
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
64 Length@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
65 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
66 out <- _internal_js_length[[string]Buffer >>]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
67 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
68
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
69 Append@String[left,right(String):out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
70 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
71 out <- [Build[String()]]Buffer <<[[[left]Buffer >>]concat[[right]Buffer >>]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
72 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
73
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
74 =@String[left,right(String):out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
75 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
76 out <- [[left]Buffer >>]_internal_js_eq[[right]Buffer >>]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
77 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
78
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
79 /*
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
80 =Delim[string,delims,index:outindex,after,nomatch]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
81 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
82 delim <- [delims]Index[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 If[[[string]Length]<[[delim]Length]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
85 try next <- Yes
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
86 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
87 check,mafter <- [string]Slice[[delim]Length]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 ,try next <- If[[check]=[delim]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90 outindex <- index
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 after <- Val[mafter]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
93 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
94 Val[try next]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
95 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
96 ,nomatch <- [delims]Next[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
97 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 outindex,after,nomatch <- =Delim[string,delims,~]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
99 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
100 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
101 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
102
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
103 Pattern@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
104 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
105 out <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
106 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
107
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
108 Match@String[string,cmp:num,no match,idx]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
109 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
110 n <- [string]Length
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
111 ,no match <- If[[string]=[[cmp]Slice[n]]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
112 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
113 num <- Val[n]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
114 idx <- 0
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
115 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
116 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
117
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
118 _Partition[string,delims:matched,after,not found]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
119 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
120 not found <- If[[string]=[""]] {}
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
121 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
122 [delims]Match[string]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
123 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
124 matched,after <- [string]Slice[~]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
125 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
126 [string]Slice[1] {}
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
127 { matched,after,not found <- _Partition[~,delims] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
128 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
129 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
130 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
131
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
132 Partition[string,delims:before,matched,after,not found]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
133 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
134 matched,after,not found <- _Partition[string,Pattern[delims]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
135 { dlen <- Length[~] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
136 { alen <- Length[~] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
137 before <- [string]Slice[ [[string]Length]-[[dlen]+[alen]] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
138 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
139
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
140
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
141 Dict Type ID@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
142 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
143 out <- ID[String()]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
144 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
145
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
146 Dict Bits@String[string,index:out,invalid]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
147 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
148 ,invalid <- [string]Byte[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
149 { out <- UInt32[~] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
150 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
151
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
152 _From Dict String[arr,el:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
153 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
154 out <- [arr]Append[Trunc UInt8[el]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
155 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
156
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
157 From Dict Key@String[string,data:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
158 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
159 out <- String[Fold[_From Dict String[?], Array[], data]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
160 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
161 */
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
162
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
163 String@String[string:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
164 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
165 out <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
166 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
167
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
168 /*
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
169 Replace[string,otoreplace,with:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
170 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
171 toreplace <- Pattern[otoreplace]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
172 ,delim,after <-[string]Partition[toreplace]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
173 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
174 wt <- Blueprint Of[with]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
175 If[ [[[wt]=[String()]] Or [[wt]=[String Slice()]]] Or [[wt]=[String Cat()]] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
176 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
177 replacement <- with
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
178 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
179 ,,idx <- [toreplace]Match[delim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
180 replacement <- [with]Index[idx]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
181 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
182 out <- [[~]Append[replacement]]Append[Replace[after,toreplace,with]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
183 } {} {} {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
184 out <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
185 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
186 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
187
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
188 _Join[list,delim,current,index:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
189 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
190 [list]Next[index]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
191 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
192 out <- _Join[list, delim, [[current]Append[delim]]Append[String[[list]Index[~]]], ~]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
193 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
194 out <- current
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
195 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
196 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
197
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
198 Join[list,delim:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
199 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
200 [list]First
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
201 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
202 out <- _Join[list, delim, String[[list]Index[~]], ~]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
203 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
204 out <- ""
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
205 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
206 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
207
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
208 */
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
209
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
210 Starts With[thing,starts with:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
211 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
212 out <- [[thing]Slice[[starts with]Length]] = [starts with]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
213 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
214
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
215 Ends With[thing,ends with:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
216 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
217 ,compare <- [thing]Slice[ [[thing]Length] - [[ends with]Length] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
218 out <- [compare] = [ends with]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
219 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
220
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
221 If@String[str:yes,no]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
222 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
223 yes,no <- If[[str]Length]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
224 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
225
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
226 /*
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
227 _Split[list,string,delim:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
228 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
229 ,,rest <- [string]Partition[delim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
230 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
231 out <- _Split[[list]Append[~], rest, delim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
232 } {} {} {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
233 out <- [list]Append[string]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
234 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
235 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
236
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
237 Split[string,delim:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
238 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
239 If[string]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
240 { out <- _Split[(),string,delim] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
241 { out <- () }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
242 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
243 */
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
244
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
245 In[needle,haystack:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
246 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
247 If[haystack]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
248 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
249 out <- If[[[haystack]Slice[Length[needle]]]=[needle]] {}
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
250 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
251 [haystack]Slice[1] {}
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
252 { out <- [needle]In[~] }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
253 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
254 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
255 out <- No
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
256 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
257 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
258
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
259 Left Trim[string,trim:trimmed]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
260 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
261 If[ [[string]Length] > [0] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
262 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
263 first,rest <- [string]Slice[1]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
264 If[ [first]In[trim] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
265 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
266 trimmed <- Left Trim[rest, trim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
267 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
268 trimmed <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
269 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
270 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
271 trimmed <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
272 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
273 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
274
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
275 Right Trim[string,trim:trimmed]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
276 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
277 If[ [[string]Length] > [0] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
278 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
279 rest,last <- [string]Slice[ [[string]Length] - [1]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
280 If[ [last]In[trim] ]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
281 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
282 trimmed <- Right Trim[rest, trim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
283 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
284 trimmed <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
285 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
286 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
287 trimmed <- string
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
288 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
289 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
290
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
291 Trim[string,trim:trimmed]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
292 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
293 left <- Left Trim[string, trim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
294 trimmed <- Right Trim[left, trim]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
295 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
296
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
297 /*
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
298 Contains[haystack,needle:out]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
299 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
300 [haystack]Partition[needle]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
301 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
302 out <- Yes
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
303 } {} {} {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
304 out <- No
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
305 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
306 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
307 */
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
308
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
309 After[text,prefix:after,not found]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
310 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
311 If[[text]Starts With[prefix]]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
312 {
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
313 ,after <- [text]Slice[[prefix]Length]
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
314 }{
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
315 not found <- text
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
316 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
317 }
fc3815b7462f Javascript backend now produces working code for some simple examples, still more of the standard lib that needs to be ported.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
318