picolisp

Unnamed repository; edit this file to name it for gitweb.
git clone https://logand.com/git/picolisp.git/
Log | Files | Refs | README | LICENSE

big.l (2949B)


      1 # 09jul11abu
      2 # (c) Software Lab. Alexander Burger
      3 
      4 ### format ###
      5 (test "123456789" (format 123456789))
      6 (test "12346" (format 12345.6789))
      7 (test "1234567.89" (format 123456789 2))
      8 (test "1234567,89" (format 123456789 2 ","))
      9 (test "1.234.567,89" (format 123456789 2 "," "."))
     10 (test 123456789 (format "123456789"))
     11 (test 12345678900 (format "1234567.89" 4))
     12 (test NIL (format "1.234.567,89"))
     13 (test 12345678900 (format "1234567,89" 4 ","))
     14 (test NIL (format "1.234.567,89" 4 ","))
     15 (test 12345678900 (format "1.234.567,89" 4 "," "."))
     16 (test 123456 (format (1 "23" (4 5 6))))
     17 
     18 
     19 ### + ###
     20 (test 6 (+ 1 2 3))
     21 (test 0 (+ 1 2 -3))
     22 (test NIL (+ NIL 7))
     23 
     24 
     25 ### - ###
     26 (test -7 (- 7))
     27 (test 7 (- -7))
     28 (test 6 (- 7 2 -1))
     29 (test NIL (- NIL 7))
     30 
     31 
     32 ### inc ###
     33 (test 8 (inc 7))
     34 (test -6 (inc -7))
     35 (test 0 (inc -1))
     36 (test 1 (inc 0))
     37 (test (8 -6 0 1) (let L (7 -7 -1 0) (map inc L) L))
     38 (test NIL (inc NIL))
     39 (let N 0
     40    (test 1 (inc 'N))
     41    (test 1 N)
     42    (test 8 (inc 'N 7))
     43    (test 8 N) )
     44 (let L (1 2 3 4)
     45    (test 3 (inc (cdr L)))
     46    (test (1 3 3 4) L) )
     47 
     48 
     49 ### dec ###
     50 (test 7 (dec 8))
     51 (test -8 (dec -7))
     52 (test -1 (dec 0))
     53 (test (7 -8 -1) (let L (8 -7 0) (map dec L) L))
     54 (test NIL (dec NIL))
     55 (let N 7
     56    (test 6 (dec 'N))
     57    (test 6 N)
     58    (test 3 (dec 'N 3))
     59    (test 3 N) )
     60 
     61 
     62 ### * ###
     63 (test 6 (* 1 2 3))
     64 (test -60 (* -5 3 2 2))
     65 (test NIL (* NIL 7))
     66 
     67 
     68 ### */ ###
     69 (test 6 (*/ 3 4 2))
     70 (test -247 (*/ 1234 -2 10))
     71 (test 17 (*/ 100 6))
     72 (test NIL (*/ 3 4 NIL))
     73 
     74 
     75 ### / ###
     76 (test 4 (/ 12 3))
     77 (test -5 (/ 60 -3 2 2))
     78 (test NIL (/ 10 NIL))
     79 
     80 
     81 ### % ###
     82 (test 2 (% 17 5))
     83 (test -2 (% -17 5))
     84 (test 1 (% 5 2))
     85 (test 5 (% 15 10))
     86 (test 1 (% 15 10 2))
     87 (test NIL (% NIL 7))
     88 
     89 
     90 ### >> ###
     91 (test 4 (>> 1 8))
     92 (test 2 (>> 3 16))
     93 (test 128 (>> -3 16))
     94 (test -32 (>> -1 -16))
     95 
     96 
     97 ### lt0 ###
     98 (test -2 (lt0 -2))
     99 (test NIL (lt0 7))
    100 (test NIL (lt0 0))
    101 
    102 
    103 ### le0 ###
    104 (test -7 (le0 -7))
    105 (test NIL (le0 2))
    106 (test 0 (le0 0))
    107 
    108 
    109 ### ge0 ###
    110 (test 7 (ge0 7))
    111 (test NIL (ge0 -2))
    112 (test 0 (ge0 0))
    113 
    114 
    115 ### gt0 ###
    116 (test 7 (gt0 7))
    117 (test NIL (gt0 -2))
    118 (test NIL (gt0 0))
    119 
    120 
    121 ### abs ###
    122 (test 7 (abs -7))
    123 (test 7 (abs 7))
    124 (test NIL (abs NIL))
    125 
    126 
    127 ### bit? ###
    128 (test 7 (bit? 7 15 255))
    129 (test 1 (bit? 1 3))
    130 (test NIL (bit? 1 2))
    131 
    132 
    133 ### & ###
    134 (test 2 (& 6 3))
    135 (test 1 (& 7 3 1))
    136 (test NIL (& 7 NIL))
    137 
    138 
    139 ### | ###
    140 (test 3 (| 1 2))
    141 (test 15 (| 1 2 4 8))
    142 (test NIL (| NIL 1))
    143 
    144 
    145 ### x| ###
    146 (test 5 (x| 2 7))
    147 (test 4 (x| 2 7 1))
    148 (test NIL (x| NIL 1))
    149 
    150 
    151 ### sqrt ###
    152 (test 8 (sqrt 64))
    153 (test 31 (sqrt 1000))
    154 (test 32 (sqrt 1000 T))
    155 (test 100000000000000000000
    156    (sqrt 10000000000000000000000000000000000000000) )
    157 (test NIL (sqrt NIL))
    158 
    159 
    160 ### seed rand hash ###
    161 (test (if (== 64 64) -1883594281 -1007791040) (seed "init string"))
    162 (test (if (== 64 64) 1699219178 -1053142179) (rand))
    163 (test (if (== 64 64) 494771840 1884033960) (rand))
    164 (test (if (== 64 64) 3 3) (rand 3 9))
    165 (test (if (== 64 64) 3 6) (rand 3 9))
    166 (test 1 (hash 0))
    167 (test 55682 (hash 1))
    168 (test 35970 (hash 7))
    169 (test 29691 (hash 1234567))
    170 
    171 # vi:et:ts=3:sw=3