r2/test2.tng
author Tony Garnock-Jones <tonygarnockjones@gmail.com>
Wed, 16 Jan 2019 17:15:58 +0000
changeset 438 1fe179d53161
parent 32 6c53aceebafd
permissions -rw-r--r--
Add missing primitive implementation for the plain interpreter.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     1
let valid-orders = map [x: [x, x]] ['sale_date', 'cost', 'address'] in
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     2
let [_, order] = Find: [[l, r]: l == order] In: valid-orders
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     3
                 IfAbsent: [_, 'sale_date']
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     4
in ...
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     5
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     6
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     7
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     8
[x: x] 1
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
     9
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    10
[[x: x] 1]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    11
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    12
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    13
[1 2 3]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    14
[(1 2) 3]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    15
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    16
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    17
[A: (1 B: 2)]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    18
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    19
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    20
[1 B: 2]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    21
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    22
[succ 1, succ 2]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    23
[(succ 1), (succ 2)]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    24
[[succ 1], [succ 2]]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    25
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    26
[succ 1]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    27
[add 1 2]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    28
[(add 1 2)]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    29
(add 1 2)
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    30
([add 1 2])
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    31
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    32
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    33
[[head]: 1 [tail]: 2] [head]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    34
[x: x + 1]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    35
[_: [x]]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    36
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    37
[(x)]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    38
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    39
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    40
`(`head: 1 `tail: 2)
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    41
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    42
`(x: x + 1)
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    43
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    44
`(succ 1, succ 2)
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    45
`(;succ 1, ;succ 2)
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    46
`(;(succ 1), ;(succ 2))
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    47
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    48
define map [
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    49
  f: [#nil            : #nil
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    50
      [#hd: h #tl: t] : [#hd: f h #tl: map f t]]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    51
];;
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    52
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    53
let valid-orders = [#sale_date, #cost, #address] collect: [x: [x, x]] in
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    54
let [_, order] = find: [[l, r]: l == order] in: valid-orders ""
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    55
                 ifAbsent: [_, #sale_date]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    56
in ...
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    57
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    58
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    59
let valid-orders = [sale_date, cost, address] collect: [x: [(x), (x)]] in
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    60
let [_, order] = find: [[l, r]: l == order] in: valid-orders ""
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    61
                 ifAbsent: [_, #sale_date]
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    62
in ...
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    63
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    64
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    65
let valid-orders = {Fun (let v = [sale_date, cost, address] in zip v v)} in
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    66
let order = ([_: [sale_date]] \ valid-orders) order in
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    67
...
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    68
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    69
6c53aceebafd Uncurry test.tng; some new experiments
Tony Garnock-Jones <tonyg@lshift.net>
parents:
diff changeset
    70
[_: [sale_date]] \