Linda, Björn has a wonderful answer for your problem as I understood it.
Here is another example. Suppose
f =: 4 : 'x * y'
Then f/ 5 4 3 2 1 is 5 f 4 f 3 f 2 f 1 so
f/ 5 4 3 2 1
120
The following shows the intermediate results
}: f /\. 5 4 3 2 1
120 24 6 2
That is, working f/ 5 4 3 2 1 from right to left, first x is 2 and y is
1 with result 2; next x is 3 and y is 2 with result 6; next x is 4 and y
is 6 with result 24; and finally x is 5 and y is 24 with result 120.
Kip
On 1/2/2012 12:50 PM, Björn Helgason wrote:
> why=: 4 : 0
> smoutput 'x'
> smoutput x
> smoutput 'y'
> smoutput y
> x + 10*y
> )
> why /|. 1 2 3 4 5
> x
> 2
> y
> 1
> x
> 3
> y
> 12
> x
> 4
> y
> 123
> x
> 5
> y
> 1234
> 12345
>
>
> 2012/1/2 Linda Alvord<[email protected]>
>
>> I think you missed the problem. The definition why expects both a left
>> and a right argument. The original post shows no definition for x . So
>> erase any definition of x that might be floating around.
>>
>> why=: 13 :'x + 10*y'/|. 1 2 3 4 5
>> erase names 'x'
>> 1
>> why
>> 12345
>>
>> The result has been produced without a value for x :
>>
>> x
>> |value error: x
>>
>> There is only one noun that the verb is supplied with in a dyadic
>> definition. How can it have a result?
>>
>> Linda
>>
>> -----Original Message-----
>> From: [email protected] [mailto:
>> [email protected]] On Behalf Of Raul Miller
>> Sent: Monday, January 02, 2012 11:28 AM
>> To: Programming forum
>> Subject: Re: [Jprogramming] Binary representation without #: or #.
>>
>> Every explicit verb has an implicit first line:
>> y=. right argument.
>>
>> Every dyadic explicit verb has an implicit second line:
>> x=. left argument
>>
>> Here, right argument and left argument are meant to represent the
>> nouns which the verb is supposed to deal with.
>>
>> The explicitly provided lines would follow the above implicit lines.
>>
>> --
>> Raul
>>
>> On Mon, Jan 2, 2012 at 11:18 AM, Linda Alvord<[email protected]>
>> wrote:
>>> Now I have a new problem:
>>>
>>> why=: 13 :'x + 10*y'/|. 1 2 3 4 5
>>> erase names 'x'
>>> 1
>>> why
>>> 12345
>>> x
>>> |value error: x
>>>
>>> What is x in why ?
>>>
>>> -----Original Message-----
>>> From: [email protected]
>>> [mailto:[email protected]] On Behalf Of Aai
>>> Sent: Monday, January 02, 2012 5:42 AM
>>> To: Programming forum
>>> Subject: Re: [Jprogramming] Binary representation without #: or #.
>>>
>>>
>>>
>>> On 02-01-12 11:21, Linda Alvord wrote:
>>>> This was a while ago, but how about a simple J version:
>>>>
>>>> brila=: 13 :'([:(++:)/|.)"1 y'
>>>> brila
>>>> ([: (+ +:)/ |.)"1
>>>> n=:5 3$ 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0
>>>> n
>>>> 0 0 0
>>>> 0 0 1
>>>> 0 1 0
>>>> 0 1 1
>>>> 1 0 0
>>>> brila n
>>>> 0 1 2 3 4
>>>>
>>>> I'm still puzzled by how it works:
>>> #. 1 0 1 0 1 0 1
>>> 85
>>>
>>> 13 :'x + 2*y'/ |. 1 0 1 0 1 0 1
>>> 85
>>>
>>> or
>>>
>>> 13 :'x + +: y'/ |. 1 0 1 0 1 0 1
>>> 85
>>>
>>>
>>> Simple J(?)
>>>
>>> 13 :'x + +: y'
>>> [ + [: +: ]
>>>
>>> or concise:
>>>
>>> (++:)
>>>
>>> Base 10 example:
>>>
>>> 13 :'x + 10*y'/ |. 1 2 3 4 5
>>> 12345
>>>
>>> (+10&*)/ |. 1 2 3 4 5
>>> 12345
>>>
>>>
>>> --
>>> Met vriendelijke groet,
>>> @@i = Arie Groeneveld
>>>
>>> ----------------------------------------------------------------------
>>> 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
>>
>> ----------------------------------------------------------------------
>> 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