[Jprogramming] Why the length error?
Linda Alvord
lindaalvord at verizon.net
Thu Oct 4 13:35:41 UTC 2012
This is the crux of the problem:
1,''
1
$1
$1,''
1
What is the simplest way to make the shape of 1,'' be empty?
Linda
-----Original Messapege-----
From: programming-bounces at forums.jsoftware.com
[mailto:programming-bounces at forums.jsoftware.com] On Behalf Of Ric Sherlock
Sent: Thursday, October 04, 2012 2:40 AM
To: programming at jsoftware.com
Subject: Re: [Jprogramming] Why the length error?
This gives a length error because
(1,'') # ''
|length error
| (1,'') #''
An simple solution to your problem is to returns the input on error:
rad=: (#~ [: -. 0 , 2 -:/\ ])@|: :: ]
rad ''
rad B
3 2
5 1
4 6
On Thu, Oct 4, 2012 at 6:41 PM, Linda Alvord <lindaalvord at verizon.net>
wrote:
>
> rad=: 13 :'(A=:1,-. 2-:/\|:y)#"1 y' NB. Remove adjacent
> duplicates
>
> ]B=:2 4 $3 5 5 4 2 1 1 6
> 3 5 5 4
> 2 1 1 6
> rad B
> 3 5 4
> 2 1 6
>
>
> The verb rad works as expected, but suppose in an earlier step B
> has become empty, I get a length error. Why does this happen?
>
>
> C=:''
> rad C
> |length error: rad
> | (A=:1,-.2-:/\|:y) #"1 y
> A
> 1
> 1#"1 C
>
> What can I do to get an empty result?
>
> Linda
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list