[Jprogramming] problem with under
Linda Alvord
lindaalvord at verizon.net
Sat Oct 29 23:15:35 HKT 2011
So the code finally provides a true or false answer for the question "Do
the digits of the two numbers match?"
a=: 10123
b=: 32110
c=: 32100
samedigits=: 13 : '-:/":^:_1 >([:(/:~~)":)&.>y'
samedigits a,c
0
samedigits a,b
1
Also, it is safer to cut and paste your code from code executed in J.
Linda
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of David Vaughan
Sent: Saturday, October 29, 2011 5:18 AM
To: Programming forum
Subject: Re: [Jprogramming] problem with under
(+/ *:) 3 4
Is
3 4 +/ *: 3 4
Is
3 4 +/ 9 16
([: +/ *:) 3 4
Is
+/ *: 3 4
Is
+/ 9 16
___________________________
David Vaughan
On 29 Oct 2011, at 08:09, "Linda Alvord" <lindaalvord at verizon.net> wrote:
> Remove either atop @ or at @: and you get:
>
> (+/ *:) 3 4
> 12 19
> 13 20
>
> but when you put in cap [: you get the result of @: rather than @
>
> ([:+/ *:) 3 4
>
> 25
>
> Linda
>
> -----Original Message-----
> From: programming-bounces at jsoftware.com
> [mailto:programming-bounces at jsoftware.com] On Behalf Of Kip Murray
> Sent: Thursday, October 27, 2011 4:03 PM
> To: Programming forum
> Subject: Re: [Jprogramming] problem with under
>
> I like especially your second form I =: ([: < [: /: ":)"0
>
> For the third form I =: < @ /: @ ": " 0 note that [: f g and f @: g are
> always equivalent, but f @: g and f @ g are not when g has rank 0 --
> conjunction @: always uses sequential processing, but conjunction @ uses
> parallel processing when g has rank 0, as shown below.
>
>
> (+/ @: *:) 3 4
> 25
>
> (+/ @ *:) 3 4
> 9 16
>
>
> In the first case above the right to left flow chart is
>
> 25 <-- +/ <-- 9 16 <-- *: <-- 3 4 (sequential processing)
>
> while in the case involving @ the flow chart is
>
> <-- 9 <-- *: <-- 3
> 9 16 <-- +/ (parallel processing because *: is rank 0)
> <-- 16 <-- *: <-- 4
>
>
> As I nearly always want sequential processing I use
>
> [: f [: g h (read "the f the g h")
>
> or
>
> f @: g @: h (read math's "f o g o h")
>
>
> Check:
>
> ([: +/ *:) 3 4
> 25
>
>
> On 10/27/2011 5:21 AM, Raul Miller wrote:
>> Also, for the domain in question, we are not using> for anything but its
> rank.
>>
>> Thus we could simplify:
>>
>> I =: ([:< [: /: [: ": ])"0
>>
>> Also, since we are always using this as a monad, we could further
> simplify:
>>
>>
>> I =: ([:< [: /: ":)"0
>>
>> Though, personally, I find myself comfortable using @
>>
>> I =:<@/:@":"0
>>
>> Or, going back to the original message, and applying @ to achieve what
>> the dictionary was talking about:
>>
>> <@([: /: ":)@>a,b
>>
>> Or, using "0 to replace @>
>>
>> <@([: /: ":)"0 a,b
>>
>> But if you are using trains in boxes, maybe it's better to state that
>> explicitly, and that could also get rid of any of the @ conjunctions:
>>
>> ([: /: ":) L:0<"0 a,b
>>
>> That said, when you replace a shorter expression with a longer one, I
>> think you should expect the longer one to lose some of the grace of
>> the original.
>>
>> I hope this helps.
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> 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