[Jprogramming] Morning exercise
Linda Alvord
lindaalvord at verizon.net
Sun Jan 22 05:44:28 HKT 2012
The morning exercises took all day. Your exercise has been useful.
f=: [: + %
f 23
0.0434783
g=: [ + %
g 23
23.0435
h=: + %
h 23
23.0435
i=: + [ %
i 23
23
j=: + [: %
j 23
|domain error: j
| j 23
I thought I understood hooks until one day I didn't.
Linda
-----Original Message-----
From: programming-bounces at jsoftware.com
[mailto:programming-bounces at jsoftware.com] On Behalf Of km
Sent: Saturday, January 21, 2012 11:19 AM
To: Programming forum
Subject: Re: [Jprogramming] Morning exercise
You can sometimes vocalize hooks helpfully: (* %) is "times the reciprocal"
and (-: |.) is "matches the reverse". It must become instinctive to think
of the dyadic use of the first verb and the monadic use of the second.
Exercise. How are ([: f g) and ([ f g) different from (f g) ?
Kip
Sent from my iPad
On Jan 21, 2012, at 7:57 AM, "Ken Chakahwata"
<kmchakahwata at first-derivative.com> wrote:
> I have found it easier to remember hook by considering it as special case
of
> a fork, with an appropriate identity function: i.e.
>
> (f g) y <=> (] f g) y <=> (] y) f (g y)
>
> Rgds
> Ken
>
> -----Original Message-----
> From: programming-bounces at jsoftware.com
> [mailto:programming-bounces at jsoftware.com] On Behalf Of Marc Simpson
> Sent: 21 January 2012 10:57
> To: Programming forum
> Subject: Re: [Jprogramming] Morning exercise
>
> On Sat, Jan 21, 2012 at 9:39 AM, Linda Alvord <lindaalvord at verizon.net>
> wrote:
>>
>> Are there rules for specific verbs to behave differently when they are
> next
>> to each other?
>
> I'm not sure that I understand the question-you're demonstrating hooks
> in the above; given your definitions,
>
> p=: -:|.
> n=: *%
>
> the left hand verb in the train (hook) will be called in a dyadic
> context. In other words,
>
> (f g) y <=> y f (g y)
>
> as such, you're not using halve in 'p' or signum in 'n'; rather, match
> and times. Perhaps this clarifies things,
>
> p 23
> 1
> (-: |.) 23
> 1
> 23 (-: |.) 23
> 1
> 23 -: |. 23
> 1
> 23 -: (|. 23)
> 1
>
> Similarly for n,
>
> n 23
> 1
> (* %) 23
> 1
> 23 (* %) 23
> 1
> 23 * (% 23)
> 1
>
> Best,
> M
> ----------------------------------------------------------------------
> 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