all repos — min @ master

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
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
'min-test require :test
;;;

"seq" *test/describe

  ((1 2) (3 4) concat (1 2 3 4) ==) *test/assert

  ((1 2 3) first 1 ==) *test/assert

  ((1 2 3) last 3 ==) *test/assert
  
  ((1 2 3) rest (2 3) ==) *test/assert

  (4 (1 2 3) append (1 2 3 4) ==) *test/assert

  (0 (1 2 3) prepend (0 1 2 3) ==) *test/assert

  ((1 2 3 4) 2 get 3 ==) *test/assert

  ((a b c) 1 get-raw /type "sym" ==) *test/assert

  ((1 2 3 4) 222 2 set (1 2 222 4) ==) *test/assert

  ((1 2 3) "test" 1 set-sym (1 test 3) ==) *test/assert

  ((1 2 3 4) 2 remove (1 2 4) ==) *test/assert

  ((1 2 3 4) 333 2 insert (1 2 333 3 4) ==) *test/assert

  ((1 2 3) size 3 ==) *test/assert

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

  ((1 2 3 4) 2 in?) *test/assert

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

  ((5 4 3 2 1) reverse (1 2 3 4 5) ==) *test/assert

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

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

  ((1 2 3 4 5) 3 shorten (1 2 3) ==) *test/assert

  ((1 2 3 4 5) 3 take (1 2 3) ==) *test/assert

  ((1 2 3 4 5) 6 take (1 2 3 4 5) ==) *test/assert

  ((1 2 3 4 5) 3 drop (4 5) ==) *test/assert

  ((1 2 3 4 5) 6 drop () ==) *test/assert

  ((1 2 3 4 5) (2 >) find 2 ==) *test/assert

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

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

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

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

  ((1 2 3 4 5 6) 2 4 slice (3 4 5) ==) *test/assert

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

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

  ((2 3 + 4 *) quote-map ('+ ==) find 2 ==) *test/assert 

  ((2 4 6 8) 'even? all?) *test/assert

  ((2 4 3 6 8) 'even? all? not) *test/assert

  ((1 2 3 4) 'odd? one? not) *test/assert

  ((1 2 4) 'odd? one?) *test/assert

  ((1 2 3 4) 'odd? any?) *test/assert

  ((2 4 6 8) 'odd? any? not) *test/assert

  ((1 2 "test") ("test" "a" true 1) intersection (1 "test") ==) *test/assert

  ((1 2 "test") ("test" "a" true 1) union (true 1 "test" "a" 2) ==) *test/assert

  ((1 2 "test") ("test" "a" true 1) difference (2) ==) *test/assert

  ((1 2 "test") ("test" "a" true 1) symmetric-difference (true "a" 2) ==) *test/assert

  *test/report
  clear-stack