But what could functional programmers do?

   (m,:n) (0&({::)`(1&({::))}@:(,&<)"1 _) y
PGCNJ
ALHIT

Yet, they might still get conjunctivitis due to a conjunctival irritation. 
(Sorry, I could not resist.)




________________________________
From: Roger Hui <[email protected]>
To: Programming forum <[email protected]>
Sent: Mon, April 12, 2010 12:23:26 AM
Subject: Re: [Jprogramming] Amend

  y=: a.{~ (a.i.'A')+i.4 5
  m=: 3 1 0 2 1
  m}y
PGCNJ
  n=: 0 2 1 1 3
  n}y
ALHIT

  (m,:n) 4 : 'x}y'"1 _ y
PGCNJ
ALHIT

That is the nature of operator (adverbial or conjunctival) arguments:
you can not slice and dice them with other operators.
Use of explicit definition overcomes this flaw.



----- Original Message -----
From: "R.E. Boss" <[email protected]>
Date: Sunday, April 11, 2010 8:44
Subject: [Jprogramming] Amend
To: 'Programming forum' <[email protected]>

> In the vocabulary 
> http://www.jsoftware.com/help/dictionary/d530n.htm the
> following example is given:
> 
>    y=: a.{~(a.i.'A')+i.4 5
>    m=: 3 1 0 2 1
>    y;m;m}y
> +-----+---------+-----+
> |ABCDE|3 1 0 2 1|PGCNJ|
> |FGHIJ|         
> |     |
> |KLMNO|         
> |     |
> |PQRST|         
> |     |
> +-----+---------+-----+
> 
> But what if n=: 0 2 1 1 3  and I want (n,:m) } y ?
> 
>    (n,:m)}y
> |rank error
> |       (n,:m)}y
> 
> I could do
> 
>    (n,:m) } ,:"1~y
> ALHIT
> PGCNJ
> 
> but that is neither elegant nor efficient.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to