Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,12 @@
LINK(L₁,1)→A
LINK(L₁+10,2)→B
LINK(L₁+50,3)→C
INSERT(A,B)
INSERT(A,C)
A→I
While I≠0
Disp VALUE(I)▶Dec,i
NEXT(I)→I
End

View file

@ -0,0 +1,30 @@
start: LDA load
ADD car ; head of list
STA ldcar
ADD one
STA ldcdr
ldcar: NOP
STA value
ldcdr: NOP
BRZ done ; 0 == NIL
STA car
JMP start
done: LDA value
STP
load: LDA 0
value: 0
car: 28 ; head of list
one: 1
20,21: 6, 0
22,23: 2, 26
24,25: 5, 20
26,27: 3, 30
28,29: 1, 22
30,31: 4, 24

View file

@ -0,0 +1,24 @@
(define friends '( albert ludwig elvis 🌀))
(for-each write friends)→ albert ludwig elvis 🌀
; for loop
(for ((friend friends)) (write friend)) → albert ludwig elvis 🌀
; map a function
(map string-upcase friends) → ("ALBERT" "LUDWIG" "ELVIS" "🌀")
(map string-randcase friends) → ("ALBerT" "LudWIG" "elVis" "🌀")
; recursive way
(define (rscan L)
(unless (null? L)
(write (first L))
(rscan (rest L))))
(rscan friends) → albert ludwig elvis 🌀
; folding a list
; check that ∑ 1..n = n (n+1)/2
(define L (iota 1001))
(foldl + 0 L) → 500500 ; 1000 * 1001 / 2

View file

@ -0,0 +1,26 @@
type Node[T] = ref object
next: Node[T]
data: T
proc newNode[T](data: T): Node[T] =
Node[T](data: data)
var a = newNode 12
var b = newNode 13
var c = newNode 14
proc insertAppend(a, n: var Node) =
n.next = a.next
a.next = n
a.insertAppend(b)
b.insertAppend(c)
iterator items(a: Node) =
var x = a
while x != nil:
yield x
x = x.next
for item in a:
echo item.data

View file

@ -0,0 +1,2 @@
: testLink LinkedList new($A, null) dup add($B) dup add($C) ;
testLink apply(#println)

View file

@ -0,0 +1,9 @@
<@ LETCNSLSTLIT>public holidays|開國紀念日^和平紀念日^婦女節、兒童節合併假期^清明節^國慶日^春節^端午節^中秋節^農曆除夕</@>
<@ OMT>From First to Last</@>
<@ ITEFORSZELSTLIT>public holidays|
<@ SAYLST>...</@><@ ACTMOVFWDLST>...</@>
</@>
<@ OMT>From Last to First (pointer is still at end of list)</@>
<@ ITEFORSZELSTLIT>public holidays|
<@ SAYLST>...</@><@ ACTMOVBKWLST>...</@>
</@>

View file

@ -0,0 +1,9 @@
<# 指定构造列表字串>public holidays|開國紀念日^和平紀念日^婦女節、兒童節合併假期^清明節^國慶日^春節^端午節^中秋節^農曆除夕</#>
<# 忽略>From First to Last</#>
<# 迭代迭代次数结构大小列表字串>public holidays|
<# 显示列表>...</#><# 运行移位指针向前列表>...</#>
</#>
<# 忽略>From Last to First (pointer is still at end of list)</#>
<# 迭代迭代次数结构大小列表字串>public holidays|
<# 显示列表>...</#><# 运行移位指针向后列表>...</#>
</#>

View file

@ -0,0 +1,32 @@
11101000000000100000000000000000 0. -23 to c
10011000000000010000000000000000 1. Sub. 25
10010000000001100000000000000000 2. c to 9
10101000000000010000000000000000 3. Sub. 21
11010000000001100000000000000000 4. c to 11
10010000000000100000000000000000 5. -9 to c
10010000000001100000000000000000 6. c to 9
11010000000000100000000000000000 7. -11 to c
11010000000001100000000000000000 8. c to 11
00000000000000000000000000000000 9. to be generated at run time
00101000000001100000000000000000 10. c to 20
00000000000000000000000000000000 11. to be generated at run time
00000000000000110000000000000000 12. Test
00011000000000000000000000000000 13. 24 to CI
10011000000001100000000000000000 14. c to 25
10011000000000100000000000000000 15. -25 to c
10011000000001100000000000000000 16. c to 25
01101000000000000000000000000000 17. 22 to CI
00101000000000100000000000000000 18. -20 to c
00000000000001110000000000000000 19. Stop
00000000000000000000000000000000 20. variable: negation of car
10000000000000000000000000000000 21. constant 1
11111111111111111111111111111111 22. constant -1
00000000000000100000000000000000 23. -0 to c
10001000000000000000000000000000 24. constant 17 (jump target)
00111000000000000000000000000000 25. 28 (pointer variable)
01000000000000000000000000000000 26. 2
01111000000000000000000000000000 27. pointer: 30
10000000000000000000000000000000 28. 1
01011000000000000000000000000000 29. pointer: 26
11000000000000000000000000000000 30. 3
00000000000000000000000000000000 31. 0 (nil)

View file

@ -0,0 +1,7 @@
var list = 'a':'b':'c':nil;
#var list = ['a', ['b', ['c']]];
#var list = Pair.new('a', Pair.new('b', Pair.new('c', nil)));
for (var l = list; l != nil; l = l[1]) {
say l[0];
}

View file

@ -0,0 +1,2 @@
each x '(1 2 3)
prn x

View file

@ -0,0 +1,2 @@
def test_list:
{ "car": 1, "cdr": { "car": 2, "cdr": { "car": 3, "cdr": null }}};