Why is @: necessary?

(1 {A=:(+/ % #) , *:@:+:)  1 2 3
4
   A
(+/ % #) , *:@:+:
   A 1 2 3
2 4 16 36
   

       (1 {B=:(+/ % #) , *:+:)  1 2 3
|domain error
|       (1{B=:(+/%#),*:+:)1 2 3
   B
(+/ % #) (, *: +:)
   
Linda

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Jose Mario 
Quintana
Sent: Wednesday, April 15, 2015 11:14 AM
To: Programming forum
Subject: Re: [Jprogramming] Verb to string and Verb array

One also would have to be careful:

    (1 { ((+/ % #) , (*:@:+:) )) 1 2 3

4

(*:@:+:) 1 2 3

4 16 36


Why?


   load'debug/dissect'

   dissect'(1 { ((+/ % #) , (*:@:+:) )) 1 2 3'



On Wed, Apr 15, 2015 at 4:26 AM, Jon Hough <[email protected]> wrote:

> Actually it seems, at least in theory, if not in practice, using forks 
> to pass a verb array is feasible.
> If I want to pass around  (+/ % #) and (*:@:+:) I could make a verb 
> verbArray =:  ((+/ % #) , (*:@:+:) ) And I could pass it around and 
> call 0{verbArray to execute and get the result of the first verb with 
> some argument, and 1{... to do the same for the second.
> Of course, the unwanted verb still gets executed, so it seems a silly 
> idea, but feasible.
>
> > From: [email protected]
> > To: [email protected]
> > Date: Wed, 15 Apr 2015 08:14:42 +0000
> > Subject: Re: [Jprogramming] Verb to string and Verb array
> >
> > In addition, I was thinking that in
> >    (1{k) 5
> > 0.2
> >
> > the (1{k) is a so-called noun fork.
> > (n u v) y is defined to be n u (v y) and therefore:
> >
> >    1 { (k 5)
> > 0.2
> >
> > because
> >    k 5
> > 5 0.2 1
> >
> > (which is not an average, indeed)
> >
> > Ben
> > ________________________________________
> > From: [email protected] [
> [email protected]] on behalf of Rob Hodgkinson 
> [ [email protected]]
> > Sent: Wednesday, April 15, 2015 10:08
> > To: [email protected]
> > Subject: Re: [Jprogramming] Verb to string and Verb array
> >
> > John, notice subtle difference in what you typed:
> >
> > k=:((+/),%,#    (this is a train of 5 verbs, as ‘,’ is also a verb used
> twice in this verb train, so you are catenating the result of the 3 verbs
> (+/)   then % then #, so the result is a 3 item list.
> >
> > as opposed to the real fork for average below, which returns an atom.
> >
> > a=:(+/)%#
> >
> >    k 5
> > 5 0.2 1
> >    a 5
> > 5
> >
> > So your (1{k) 5 is actually a new function indexing into item 1 of 
> > the
> result of k as Raul described below… (it is not indexing to the % and 
> applying that to 5 which you may have thought)...
> > whereas (1{a) 5 returns index error (since a returns an atom).
> >
> > Hope this is clear now, Regards Rob
> >
> >
> > > On 15 Apr 2015, at 5:57 pm, Raul Miller <[email protected]> wrote:
> > >
> > > Technically, you are not indexing the tines of the fork but you 
> > > are indexing the result of the fork.
> > >
> > > Thanks,
> > >
> > > --
> > > Raul
> > >
> > >
> > > On Wed, Apr 15, 2015 at 3:09 AM, Jon Hough <[email protected]>
> wrote:
> > >> Yes, thanks. It seems more clear. I wasn't aware you could index
> tines of a fork.e.g.
> > >>
> > >> k =: ((+/),%,#)
> > >>
> > >>
> > >> (1{k) 5
> > >> gives 0.2
> > >> That was the main cause of confusion. Thanks.
> > >>
> > >>> From: [email protected]
> > >>> Date: Wed, 15 Apr 2015 02:55:14 -0400
> > >>> To: [email protected]
> > >>> Subject: Re: [Jprogramming] Verb to string and Verb array
> > >>>
> > >>> k is a single verb which produces 3 values for each element of 
> > >>> its
> argument.
> > >>>
> > >>> It is also a fork, and each tine of the fork has a leaf which is 
> > >>> a bond (n&v). So if you give it a left argument, that becomes a 
> > >>> repeat count for those operations.
> > >>>
> > >>> There are some other properties which you can observe by 
> > >>> inspection (each tine of the fork is composed of rank zero verbs, for 
> > >>> example).
> > >>>
> > >>> Does that help?
> > >>>
> > >>> Thanks,
> > >>>
> > >>> --
> > >>> Raul
> > >>>
> > >>> On Wed, Apr 15, 2015 at 2:34 AM, Jon Hough <[email protected]>
> wrote:
> > >>>> I am slightly confused with how the tie (gerund) and or the 
> > >>>> linear
> representation are related to this:
> > >>>>
> > >>>> k =: (^@:(3&*)) d. 1 2 3
> > >>>>
> > >>>>
> > >>>> results in :
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> ((3"0 * ^@(3&*)) , (9"0 * ^@(3&*)) , 27"0 * ^@(3&*))"0
> > >>>>
> > >>>>
> > >>>> Which seems to be three verbs; If I do :
> > >>>> k 3
> > >>>>
> > >>>>
> > >>>> I get :
> > >>>>
> > >>>>
> > >>>> 24309.3 72927.8 218783
> > >>>> And I can also do:
> > >>>>
> > >>>>
> > >>>> (0{k) 3
> > >>>>
> > >>>>
> > >>>> 24309.3
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>> So whatever k is, it returns three nouns for one input noun, 
> > >>>> and it
> is indexable so is an array of some sort. But what exactly (in terms 
> of
> parts-of-speech) is k?
> > >>>>
> > >>>>
> > >>>>
> > >>>>> Date: Tue, 14 Apr 2015 18:59:52 +0200
> > >>>>> From: [email protected]
> > >>>>> To: [email protected]
> > >>>>> Subject: Re: [Jprogramming] Verb to string and Verb array
> > >>>>>
> > >>>>> Exactly. Actually, any time you want something to work as if 
> > >>>>> it
> were
> > >>>>> assigned to a name, you'd need brackets.
> > >>>>> Eg: *: +&. won't work, while *: (+&.) will. But this might be 
> > >>>>> out
> of your
> > >>>>> scope, since +&. is an adverb, not a verb.
> > >>>>>
> > >>>>> 2015-04-14 17:35 GMT+02:00 Jon Hough <[email protected]>:
> > >>>>>
> > >>>>>> Thanks,
> > >>>>>> Just to be clear, '(',')',~  is just to bracketify the verb 
> > >>>>>> so
> its fork
> > >>>>>> (in this case) works, right?
> > >>>>>>
> > >>>>>> --- Original Message ---
> > >>>>>>
> > >>>>>> From: "Jan-Pieter Jacobs" <[email protected]>
> > >>>>>> Sent: April 14, 2015 5:26 PM
> > >>>>>> To: [email protected]
> > >>>>>> Subject: Re: [Jprogramming] Verb to string and Verb array
> > >>>>>>
> > >>>>>> Hey John,
> > >>>>>>
> > >>>>>> I think 1. you can do using 5!:5:
> > >>>>>>
> > >>>>>>   mean =: +/%#
> > >>>>>>   mean i.5
> > >>>>>> 2
> > >>>>>>   5!:5 <'mean'
> > >>>>>> +/ % #
> > >>>>>>   datatype 5!:5 <'mean'
> > >>>>>> literal
> > >>>>>>   ". (('(',')',~5!:5) <'mean'),'0 1 2 3 4'
> > >>>>>> 2
> > >>>>>>   stringify =: '(',')',~5!:5
> > >>>>>>   (stringify <'mean') , '0 1 2 3 4'
> > >>>>>> (+/ % #)0 1 2 3 4
> > >>>>>>
> > >>>>>> For point 2, you can use gerunds to pass around verbs in a list:
> > >>>>>>
> > >>>>>>   ger =: +`-`*`%
> > >>>>>>   ger
> > >>>>>> ┌─┬─┬─┬─┐
> > >>>>>> │+│-│*│%│
> > >>>>>> └─┴─┴─┴─┘
> > >>>>>>   10 ((1{ger) `: 0) 20
> > >>>>>> _10
> > >>>>>>
> > >>>>>> There's a massive amount of uses for gerunds, like / , ^: , } 
> > >>>>>> ,
> and so
> > >>>>>> on...
> > >>>>>>
> > >>>>>> If you'd want to do these things (make a noun (or list there 
> > >>>>>> of))
> out of
> > >>>>>> any type of word, I think you should be looking at atomic
> representation.
> > >>>>>>
> > >>>>>> Jan-Pieter
> > >>>>>>
> > >>>>>> 2015-04-14 10:11 GMT+02:00 Jon Hough <[email protected]>:
> > >>>>>>
> > >>>>>>> I have a couple of questions:
> > >>>>>>> 1. Is it possible to convert a verb, e.g. +/%# ,  to a string?":
> '+/%# 2
> > >>>>>> 3
> > >>>>>>> 4' executes a stringed verb with an argument. But how would 
> > >>>>>>> I
> convert a
> > >>>>>>> verb to a string in the first place?
> > >>>>>>> Also, I discovered the eval verb
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> eval=: 1 : 0
> > >>>>>>>
> > >>>>>>> ". 'w =. ' , u
> > >>>>>>>
> > >>>>>>> (ar < 'w') ab
> > >>>>>>>
> > >>>>>>> )
> > >>>>>>>
> > >>>>>>>
> > >>>>>>> Does this have an inverse?
> > >>>>>>>
> > >>>>>>> 2. If I have two verbs (or conjunctions, adverbs for that
> matter), can I
> > >>>>>>> not pass them around in a list?
> > >>>>>>> e.g. in other languages, like C# I can put functions into a 
> > >>>>>>> list (List<Action> for example).
> > >>>>>>> I searched JforC and the J website and couldn't find any way 
> > >>>>>>> to
> do this.
> > >>>>>>> Thanks Jon
> > >>>>>>>
> ----------------------------------------------------------------------
> > >>>>>>> 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
> > >>
> > >> -----------------------------------------------------------------
> > >> ----- 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

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to