-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsample.lc
154 lines (151 loc) · 3.05 KB
/
sample.lc
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
print("hello", 0x16, 16, 1.6, [1, 2, 3])
print({"foo": "bar"})
print({foo="bar"})
print([1, 2, 3]...)
print(%"<<")
print(1+2+3)
greet = "hello world"
print(greet)
foo = (argv...):
print(argv)
foo(1,2,3,4)
# test = :exnihilo()
# x = 40
# y = 20
# blonk = ():
# x := 10
# print("blonk")
# print(test, test.x)
# test.blonk()
# print(test, test.x)
#
# if false
# print("hello false")
# elif null
# print("hello null")
# else
# print("hello world")
#
# if false
# print("hello hulla")
# elif true
# print("hello elif")
#
# print("hello world")
# print(null, true, false)
# print(1, 2, 1 + 2, -(4*1))
#
# class vec2 extends object
# +init = (self, x, y):
# self.x = x
# self.y = y
# +iter = (self):
# return iter([self.x, self.y])
# +repr = (self):
# return "vec2(" ++ repr(self.x) ++ ", " ++ repr(self.y) ++ ")"
#
# a = vec2(0.5, 0.2)
# b = vec2(0.8, 0.4)
# c = vec2(0.3, 0.6)
#
# %"+expr"[[vec2]] = (a):
# return a
#
# %"-expr"[[vec2]] = (a):
# return vec2(-a.x, -a.y)
#
# %"+"[[vec2, vec2]] = (a, b):
# return vec2(a.x+b.x, a.y+b.y)
#
# %"-"[[vec2, vec2]] = (a, b):
# return vec2(a.x-b.x, a.y-b.y)
#
# %"*"[[vec2, float]] = (a, b):
# return vec2(a.x*b, a.y*b)
#
# %"*"[[float, vec2]] = (a, b):
# return vec2(a*b.x, a*b.y)
#
# %"/"[[vec2, float]] = (a, b):
# return vec2(a.x/b, a.y/b)
#
# %"/"[[float, vec2]] = (a, b):
# return vec2(a/b.x, a/b.y)
#
# print(a)
# print(b)
# print(a + b)
# print(1.1 + 1.2)
#
# print("iterating vector")
# for i in b
# print(i)
#
# dot = multimethod(2)
# print(dot)
#
# k = 0
# while k < 10
# print("K", k)
# k += 1
#
# foo = exnihilo()
# foo.a = 4
# foo.a += 1
# print("a:", foo.a)
#
# foo = [0]
# foo[0] += 1
# print("[0]:", foo[0])
#
#
# test = (first=4, foo...):
# print(first)
# print(foo)
#
# test(1,2,3)
# test(null, 5)
# test()
#
#
# while true
# print("breaking out of while")
# break
# #
# # try
# # try
# # print("trying to raise error")
# # not_present_here()
# # except Exception as x
# # print("got", interface(x), ":", x)
# # print("and traceback:", x.traceback)
# # print("we could raise it again..")
# # raise x
# # except Exception as x
# # print("..or we could just exit")
# #
# # # primitives available (int,float,string,list)
# # # locals/globals available
# # # some of the operators available
# # # list literal available
# # # if/elif/else available
# # # function call available
# # # function return available
# # # while available
# # # local assign available
# # # simple indexing available
# # # getattr available
# # # for loop available
# # # function available
# # # upscope lookup available
# # # upscope assign available
# # # setitem/setattr available
# # # dict literals available
# # # classes available
# # # function varargs available
# # # raise available
# # # while break/continue available
# #
# # # scope block capture missing.
# # # generators missing, yield missing
# # # assert missing