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,5 @@
Lbl INSERT
{r₁+2}ʳ→{r₂+2}ʳ
r₂→{r₁+2}ʳ
r₁
Return

View file

@ -0,0 +1,11 @@
(define (insert-after lst target item)
(when (null? lst) (error "cannot insert in" null))
(let [(sub-list (member target lst))]
(if sub-list (set-cdr! sub-list (cons item (cdr sub-list))) ; make chirurgy if found
(nconc lst item)))) ; else append item
(define L '(a b))
(insert-after L 'a 'c)
L → (a c b)
(insert-after L 'x 'y)
L → (a c b y)

View file

@ -0,0 +1,17 @@
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)

View file

@ -0,0 +1,16 @@
Collection Class new: LinkedList(data, mutable next)
LinkedList method: initialize := next := data ;
LinkedList method: data @data ;
LinkedList method: next @next ;
LinkedList method: add(e) e @next LinkedList new := next ;
LinkedList method: forEachNext
dup ifNull: [ drop self ]
dup 1 ifEq: [ drop false return ]
dup next dup ifNull: [ drop 1 ]
swap data true ;
: testLink LinkedList new($A, null) dup add($B) dup add($C) ;
testLink println

View file

@ -0,0 +1,18 @@
func insert_after(a,b) {
b{:next} = a{:next};
a{:next} = b;
}
var B = Hash.new(
data => 3,
next => nil, # not a circular list
);
var A = Hash.new(
data => 1,
next => B,
);
var C = Hash.new(
data => 2,
);
insert_after(A, C);