view test/g122.ijs @ 0:e0bbaa717f41 draft default tip

lol J
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Mon, 25 Nov 2013 11:56:30 -0500
parents
children
line wrap: on
line source

NB. -:y -----------------------------------------------------------------

(-: -: 0.5&*)  ?2 3 4$2
(-: -: 0.5&*)  _20+?50$50
(-: -: 0.5&*)  o. _20+?50$50
(-: -: 0.5&*)  r. ?3 4 5$100
(-: -: 0.5&*)  i.0 3 4
(-: -: 0.5&*)  i.3 0

'domain error' -: -: etx 'abc'
'domain error' -: -: etx 3;4 5


NB. x-:y ----------------------------------------------------------------

''   -: $0
''   -: 0$a:
($0) -: 0$a:

(0 3 4 5$1)   -: 0 3 4 5$4
(0 3 4 5$1)   -: 0 3 4 5$4.6
(0 3 4 5$1)   -: 0 3 4 5$4j6
(0 3 4 5$1)   -: 0 3 4 5$'a'
(0 3 4 5$1)   -: 0 3 4 5$<'a'

(0 3 4 5$456) -: 0 3 4 5$0
(0 3 4 5$456) -: 0 3 4 5$4.6
(0 3 4 5$456) -: 0 3 4 5$4j6
(0 3 4 5$456) -: 0 3 4 5$'a'
(0 3 4 5$456) -: 0 3 4 5$<'a'

(0 3 4 5$4.6) -: 0 3 4 5$0
(0 3 4 5$4.6) -: 0 3 4 5$456
(0 3 4 5$4.6) -: 0 3 4 5$4j6
(0 3 4 5$4.6) -: 0 3 4 5$'a'
(0 3 4 5$4.6) -: 0 3 4 5$<'a'

(0 3 4 5$4j6) -: 0 3 4 5$0
(0 3 4 5$4j6) -: 0 3 4 5$456
(0 3 4 5$4j6) -: 0 3 4 5$4.6
(0 3 4 5$4j6) -: 0 3 4 5$'a'
(0 3 4 5$4j6) -: 0 3 4 5$<'a'

(0 3 4 5$'j') -: 0 3 4 5$0
(0 3 4 5$'j') -: 0 3 4 5$456
(0 3 4 5$'j') -: 0 3 4 5$4.6
(0 3 4 5$'j') -: 0 3 4 5$4j6
(0 3 4 5$'j') -: 0 3 4 5$<'a'

(0 3 4 5$<56) -: 0 3 4 5$0
(0 3 4 5$<56) -: 0 3 4 5$456
(0 3 4 5$<56) -: 0 3 4 5$4.6
(0 3 4 5$<56) -: 0 3 4 5$4j6
(0 3 4 5$<56) -: 0 3 4 5$'a'

match =: 0:`(*./@:=&,)@.(-:&$)
test  =: -: = match

NB. Boolean
0 test 0
1 test 1
a test a=:?1000$2
(?2 3$2) test ?2 3 4 5$2
((}:a),-.{:a) test a=:?100$2
(}.a,5)   test a=:?100$2
(}.a,5)   test~a=:?100$2
(}.a,4.5) test a=:?100$2
(}.a,4.5) test~a=:?100$2
(}.a,4j5) test a=:?100$2
(}.a,4j5) test~a=:?100$2
(}:a,5)   test a=:?100$2
(}:a,5)   test~a=:?100$2
(}:a,4.5) test a=:?100$2
(}:a,4.5) test~a=:?100$2
(}:a,4j5) test a=:?100$2
(}:a,4j5) test~a=:?100$2

NB. literal
'a' test 'b'
a test a=:a.{~?100$256
((}:a),{:a.) test a=:a.{~?100$255
(a.{~?2 3$256) test a.{~?2 3 4 5$256
(($a)$1)        test a=:a.{~?2 3 4$255
(($a)$45)       test a=:a.{~?2 3 4$255
(($a)$4.5)      test a=:a.{~?2 3 4$255
(($a)$4j5)      test a=:a.{~?2 3 4$255
(($a)$<45)      test a=:a.{~?2 3 4$255
f =: $&'abc'            test $&'abc'
g =: ,&'d'@}:@($&'abc') test ,&'e'@}:@($&'abc')
h =: {&'ab'@:?@($&2)    test {&'ab'@:?@($&2)
f"0 i.25
g"0 i.25
h"0 i.25

NB. integer
3 test 3
3 test _3
a test a=:_1e9+?1000$2e9
(?2 3$234) test ?2 3 4 5$234
((}:a),2e9) test a=:?100$2e9
(}.a,4.5) test a=:_1e9+?100$2e9
(}.a,4.5) test~a=:_1e9+?100$2e9
(}.a,4j5) test a=:_1e9+?100$2e9
(}.a,4j5) test~a=:_1e9+?100$2e9
(}:a,4.5) test a=:_1e9+?100$2e9
(}:a,4.5) test~a=:_1e9+?100$2e9
(}:a,4j5) test a=:_1e9+?100$2e9
(}:a,4j5) test~a=:_1e9+?100$2e9

NB. real
3.5 test 3.5
3.5 test _3.5
a test a=:o._1e9+?100$2e9
(o.?2 3$234) test o.?2 3 4 5$234
((}:a),2e9)  test o.a=:?100$2e8
(}.a,4j5) test a=:o._1e9+?100$2e9
(}.a,4j5) test~a=:o._1e9+?100$2e9
(}:a,4j5) test a=:o._1e9+?100$2e9
(}:a,4j5) test~a=:o._1e9+?100$2e9

NB. complex
3j5 test 3j5
3j5 test 3j_5
a test a=:j./_1e9+?2 50$2e9
(j./?2 3$234) test j./?2 3 4 5$234
((}:a),2e9) test a=:j./?2 50$2e8

NB. boxed
(<'asdf') test <'asdf'
(<'asdf') test <'foob'
a test a=:<"1 ?300 3$1e9
((}:a),<9) test a=:<"1 ?300 3$1e9

a (-:!.0 = *./@:(=!.0)&,) a=:o._1e9+?100$2e9
(}:a,4j5)   (-:!.0 = *./@:(=!.0)&,) a=:o._1e9+?100$2e9
(}:a,4j5)   (-:!.0 = *./@:(=!.0)&,)~a=:o._1e9+?100$2e9
((}.a),4j5) (-:!.0 = *./@:(=!.0)&,) a=:o._1e9+?100$2e9
((}.a),4j5) (-:!.0 = *./@:(=!.0)&,)~a=:o._1e9+?100$2e9
((}:a),4j5) (-:!.0 = *./@:(=!.0)&,) a=:o._1e9+?100$2e9
((}:a),4j5) (-:!.0 = *./@:(=!.0)&,)~a=:o._1e9+?100$2e9

a (-:!.0 = *./@:(=!.0)&,) a=:j./_1e9+?2 50$2e9
((}.a),4j5) (-:!.0 = *./@:(=!.0)&,) a=:j./_1e9+?2 50$2e9
((}.a),4j5) (-:!.0 = *./@:(=!.0)&,)~a=:j./_1e9+?2 50$2e9
((}:a),4j5) (-:!.0 = *./@:(=!.0)&,) a=:j./_1e9+?2 50$2e9
((}:a),4j5) (-:!.0 = *./@:(=!.0)&,)~a=:j./_1e9+?2 50$2e9

1 -:!.(2^_42) 1+2^_43
1 -:!.(2^_43) 1+2^_44
1 -:!.(2^_44) 1+2^_45
1 -:!.(2^_45) 1+2^_46


NB. x-:"r y -------------------------------------------------------------

0 0 0 0 -: 1 2 3 -:"1 i.4 2
0 0 0 0 -: 1 2 3 -:"1 [4 3$'x'

1 0 0 0 1 -: 0 1 2 -:"1[5$i.4 3
(10$1) -: x-:"1 x=:?10 7$1e6

n=: 300
match=: 4 : 'x-:y'
test1=: 3 : '(c-:"1 d) -: c match"1 d=:((i.n)-?n$2){c=:((n,y)?@$2){''ab'''
test2=: 3 : '(c-:"1 e) -: c match"1 e=:(?n        ){c=:((n,y)?@$2){''ab'''

test1"0 i.3 10
test2"0 i.3 10

(-:"0/~ -: match"0/~) x=:?20$2
(-:"0/~ -: match"0/~) x=:a{~?20$#a=:'aleatoric'
(-:"0/~ -: match"0/~) x=:?20$10
(-:"0/~ -: match"0/~) x=:o.?20$10
(-:"0/~ -: match"0/~) x=:r.?20$10
(-:"0/~ -: match"0/~) x=:a{~?20$#a=:;:'deipno sop hist anti dis est a blish'

(-:"1/~ -: match"1/~) x=:a{~?20$#a=:?10 3$2
(-:"1/~ -: match"1/~) x=:a{~?20$#a=:[;.1 ' aleatoric quitrent russia'
(-:"1/~ -: match"1/~) x=:a{~?20$#a=:?10 4$1e6
(-:"1/~ -: match"1/~) x=:a{~?20$#a=:o.?10 4$1000
(-:"1/~ -: match"1/~) x=:a{~?20$#a=:r.?10 4$1000
(-:"1/~ -: match"1/~) x=:a{~?20$#a=:5 3$;:'deipno sop hist anti dis est a blish'

(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: ?3$2
(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: 'xyz'
(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: ?3$1e6
(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: o.?3$100
(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: r.?3$100
(x=:a{~?20$3) (-:"0 -: match"0) y=:a{~?20$3 [ a=: ;:'ja oder nein'

(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: ?3 5$2
(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: 3 7$'ipso facto Cogito, ergo sum.'
(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: ?3 4$3
(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: o.?3 5$3
(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: r.?3 5$3
(x=:a{~?20$3) (-:"1 -: match"1) y=:a{~?20$3 [ a=: (<'do'),.3 5$;:'pi no so hi do to an am no'

test3=: 4 : 0
 a=: x{~?(3,y)$#x
 xx=:a{~?#a
 yy=:a{~?3 5$#a
 assert. xx (-:"1 -: match"1) yy
 assert. yy (-:"1 -: match"1) xx
 1
)

0 1         test3"1 0 i.3 10
'abc'       test3"1 0 i.3 10
0 1 2       test3"1 0 i.3 10
0 1 2.3     test3"1 0 i.3 10
0 1 2j3     test3"1 0 i.3 10
(0 1;2;i.7) test3"1 0 i.3 10

test4=: 4 : 0
 a=: x{~?(3,y)$#x
 xx=:a{~?3 5 2 7$#a
 yy=:a{~?3 5$#a
 assert. xx (-:"1 -: match"1) yy
 assert. yy (-:"1 -: match"1) xx
 1
)

0 1         test4"1 0 i.3 10
'abc'       test4"1 0 i.3 10
0 1 2       test4"1 0 i.3 10
0 1 2.3     test4"1 0 i.3 10
0 1 2j3     test4"1 0 i.3 10
(0 1;2;i.7) test4"1 0 i.3 10


4!:55 ;:'a c d e f g h match n test test1 test2 test3 test4 x xx y yy'