The ident adverb I was looking for would be like:
ident2 =: 1 : 0 NB. assumes all 0 element arguments (0=#y)return identity
behaviour
y
:
if. 0=#x do. y return. end.
if. 0=#y do. x return. end.
x u y
)
ident3 =: 1 : 0 NB. assumes only i.0 arguments causes identity behaviour
y
:
if. x-:i.0 do. y return. end.
if. y-:i.0 do. x return. end.
x u y
)
+ident2 33
33
(i.0) +ident2 33
33
((i.0),ident2 22) +ident2 i.0
22
$ 22 +ident3 i.0 0
0 0
incidentally, there is a bug in the documentation for identity function,
because it says that it should behave like ident2, but it really behaves like
ident3.
----- Original Message ----
From: "Miller, Raul D" <[EMAIL PROTECTED]>
To: Programming forum <[email protected]>; Programming forum
<[email protected]>
Sent: Sunday, October 22, 2006 3:09:30 PM
Subject: RE: [Jprogramming] Dyads and identity function
ident=:1 :'a:1 :(u b.1)'
For example:
+ident 99
0
+ident i. 9 9
0 0 0 0 0 0 0 0 0
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm