f=: {.^:(1=#)
   f 'abc'
abc
   $ f 'a'

   $ f ,'a'

f^:proprosition y is equivalent to
if. proposition y do. f y else. y end.



----- Original Message -----
From: "Leigh J. Halliwell" <[EMAIL PROTECTED]>
Date: Saturday, April 7, 2007 10:14 am
Subject: [Jprogramming] Singleton Reduction

> Dear J Forum:
> 
> Let X1 =. 'A' and X2 =. 1$'A'.  Now X1 and X2 look equal, but 
> because of
> different ranks X1 does not equal X2.  I would like to reduce a 
> singleton to
> an atom.  If #X is 1, {.X does this.  But I don't want to take the 
> firstitem, if the string has more than one item.  Can someone tell 
> me a simple or
> efficient tacit expression that reduces one-rank, one-item arrays 
> to atoms,
> and leaves other one-rank arrays unchanged?  Can it be done 
> without gerunds?
> Thanks.
> 
> Sincerely,
> 
> Leigh
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to