all repos — min @ 21bdf48c7f28ec21c9678bc1ae7fca80f1257bbb

A small but practical concatenative programming language.

tests/seq.min

 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
'test load
'test import

"seq" describe

  ((1 2) (3 4) concat (1 2 3 4) ==) assert

  ((1 2 3) first 1 ==) assert

  ((1 2 3) last 3 ==) assert
  
  ((1 2 3) rest (2 3) ==) assert

  (4 (1 2 3) append (1 2 3 4) ==) assert

  (0 (1 2 3) prepend (0 1 2 3) ==) assert

  ((1 2 3 4) 2 get 3 ==) assert

  ((1 2 3 4) 222 2 set (1 2 222 4) ==) assert

  ((1 2 3 4) 2 remove (1 2 4) ==) assert

  ((1 2 3 4) 333 2 insert (1 2 333 3 4) ==) assert

  ((1 2 3) size 3 ==) assert

  ((1 2 3 4) 5 in? false ==) assert

  ((1 2 3 4) 2 in?) assert

  ((1 2 3 4) (2 +) map (3 4 5 6) ==) assert

  ((5 4 3 2 1) reverse (1 2 3 4 5) ==) assert

  ((("a" 1)("b" 2)("c" 3)) dictionary?) assert

  ((("a" 1)("b" 2)("c" 3)) 'b dget 2 ==) assert

  ((("a" 1)("b" 2)("c" 3)) ' :dict dict 5 'b dset 7 %d =newdict newdict (("a" 1)("b" 5)("c" 3)("d" 7)) ==  dict (("a" 1)("b" 2)("c" 3)) == and) assert

  ((("a" 1)("b" 2)("c" 3)) ' :dict dict 'b ddel =newdict newdict (("a" 1)("c" 3)) == dict (("a" 1)("b" 2)("c" 3)) == and) assert

  ((("a" 1)("b" 2)("c" 3)) dkeys ("a" "b" "c") ==) assert

  ((("a" 1)("b" 2)("c" 3)) dvalues (1 2 3) ==) assert

  ((("a" 4) ("c" 8) ("f" 2) ("b" 0)) dsort (("a" 4)("b" 0)("c" 8)("f" 2)) ==) assert

  ((("a" 1) ("b" 2) ("c" 3) ("d" 4)) ("b" "c") dpick (("b" 2) ("c" 3)) ==) assert

  ((3 4 7 2 4 6 5 6) '> sort  (2 3 4 4 5 6 6 7) ==) assert

  ((3 4 7 2 4 6 5 6) '< sort (7 6 6 5 4 4 3 2) ==) assert

  ((1 2 3 4 5) 3 shorten (1 2 3) ==) assert

  ((1 2 3 4 5) (2 >) find 2 ==) assert

  ((1 2 3 4 5) 1 (*) reduce 120 ==) assert

  ((1 3 5) (dup *) (+) map-reduce 35 ==) assert

  ((1 2 3 4 5 6) (odd?) partition get-stack ((1 3 5) (2 4 6)) ==) assert

  ((1 2 3 4 5 6) (odd?) reject (2 4 6) ==) assert

  ((1 2 3 4 5 6) 2 4 slice (3 4 5) ==) assert

  ((2 3 () 4 (3 4) () () "test") harvest (2 3 4 (3 4) "test") ==) assert

  ((1 2 3 (4 5 6) 7 (8 9)) flatten (1 2 3 4 5 6 7 8 9) ==) assert

  report
  clear-stack