diff test/g402.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 diff
new file mode 100644
--- /dev/null
+++ b/test/g402.ijs
@@ -0,0 +1,98 @@
+NB. #:y -----------------------------------------------------------------
+
+max    =: >./@:|@,
+bits   =: ] (1 >. ] + [ >: 2x&^@]) <.@(2&^.)@(1&>.)
+abase1 =: #:~ $&2@bits@max
+
+NB. Boolean
+(#: -: abase1) x=:?2 3 4$2
+(#: -: abase1) x=: 0
+(#: -: abase1) x=: 1
+
+NB. integer
+(#: -: abase1) x=:_6000+?2 3 4$12345
+(#: -: abase1) x=:_500+?1000
+(#: -: abase1) x=:_1e8+?100$2e8
+(#: -: abase1) x=:_2147483648
+(#: -: abase1) x=: 2147483647
+(#: -: abase1) x=:_2147483648 25 9 2147483647
+(#: -: abase1) imin
+(#: -: abase1) imax
+(#: -: abase1) x=: imax,imin,_5e8+10 ?@$ 1e9
+
+NB. floating point
+(#: -: abase1) x=:o._5000+?2 3 4$10000
+(#: -: abase1) x=:o._500+?1000
+
+0~:{.#:(2^12)-1e_9
+
+NB. complex
+(#: -: abase1) x=:j./?2 3 4$1000
+(#: -: abase1) x=:r.?12345 6789
+
+(,0)    -: #: 0
+(,1)    -: #: 1
+1 0     -: #: 2
+1 0 0   -: #: 4
+1 0 0 0 -: #: 8
+1 0 0 0 -: #: _8
+1 1 0 1 -: #: 13
+
+(70{.1) -: #: 2^69
+
+f =: ([,-.@(0&e.))@$ $ ,
+(f t) -: #:t=:?(>:?7$3)$2
+(f t) -: #:t=:(?32$2)$2
+(f t) -: #:t=:(?32$2)$2.4
+(f t) -: #:t=:(?32$2)$2j4
+
+'domain error' -: #: etx 'abc'
+'domain error' -: #: etx 123;45 6
+
+
+NB. x#:y ----------------------------------------------------------------
+
+abase2 =: ([ | i.@#@$@] |: ([%~]-|)/\.@}.@,)"1 0
+f =: *./@,@:(#: -: abase2)
+
+NB. Boolean
+(?4$2) f ?2 3 4$2
+(?4$2) f ?2
+
+NB. integer
+(?4$100)         f _6000+?2 5$12345
+(_4+?2 4$10)     f _6000+?2 1 3$12345
+(?4$10)          f _500+?1000
+(_40+?3 2 4$100) f _6000+?3$12345
+
+NB. floating point
+(_15+?1 2 4$30)  f o._5000+?1 2$10000
+(_4+?7$9)        f o._500+?10000
+
+NB. complex
+(_15+3 4$30)     f r.?3 1 1 4$1000
+(_4+?3 1 1 7$9)  f r.?3 1$12345
+
+(?2)     (|-:#:) ?2
+(?100)   (|-:#:) ?100
+(o.?100) (|-:#:) o.?100
+(r.?100) (|-:#:) r.?100
+
+1 2 3 4   -: 10 10 10 10#:1234
+0 0 _1 _1 -: _2 _2 _2 _2#:1
+
+f=: #: i.@(*/)
+g=: 3 : 'y#:i.*/y'
+
+(f -: g) ?5$5
+(f -: g) ?5$14
+(f -: g) _7+?5$14
+
+'domain error' -: 2 3 4#: etx 'abc'
+'domain error' -: 4 3 2#: etx 123;45 6
+'domain error' -: 'abc'#: etx 7
+'domain error' -: (123;4 5 6)#: etx _12
+
+4!:55 ;:'abase1 abase2 bits f g max t x '
+
+