[Jprogramming] Problem with }
Dan Bron
j at bron.us
Wed Dec 14 20:28:03 HKT 2011
The issue is that } is an adverb.
So, even though V0 } V1 looks like a verb train, it's actually a hook, parsed as (V0}) V1 , which doesn't do what you want.
You're looking for (OLD&=)`(,:&NEW) } . This is one of my very favorite J phrases.
-Dan
Please excuse typos; composed on a handheld device.
-----Original Message-----
From: "Shaw, Ewart" <Ewart.Shaw at warwick.ac.uk>
Sender: programming-bounces at jsoftware.com
Date: Wed, 14 Dec 2011 11:41:41
To: <programming at jsoftware.com>
Reply-To: Programming forum <programming at jsoftware.com>
Cc: Shaw, Ewart<Ewart.Shaw at warwick.ac.uk>
Subject: [Jprogramming] Problem with }
I'm trying to recode data using (=&OLD } ,:&NEW)
but the following happens both on J7 and J64-602:
(3 1 4 1 5 9 = 1) } 3 1 4 1 5 9,:_1 NB. OK
3 _1 4 _1 5 9
(=&1 } ,:&_1) 3 1 4 1 5 9 NB. not OK
9 1 4 1 5 9
_1 _1 _1 _1 _1 _1
A=. (=&1 ; ,:&_1) 3 1 4 1 5 9 NB. check args of }
B=. (3 1 4 1 5 9 = 1) ; 3 1 4 1 5 9,:_1
A-:B
1
Any suggestions? (I might be missing something obvious
as I've spent much of the night analysing a clinical trial!)
Many thanks, Ewart Shaw
J.E.H.Shaw http://www.warwick.ac.uk/statsdept
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list