I checked ...
the "each" operator works exactly the same in A+ with a defined function:
 The code in the defined function is re-interpreted for each element.

I had used the "each" operator primarily with primitive functions, and so,
never noticed the load it could put on the interpreter when used with a
defined function on an entity containing a large number of elements.


On Sun, Jan 8, 2012 at 8:36 PM, Tom Szczesny <tav...@gmail.com> wrote:

> Yes --
> the conjuction explanation makes a lot more sense ...
> The application of cutl  a 'record' at a time becomes apparent before the
> first line of code in cutl is executed.
>
>    load 'debug'
>    dbss 'cutl *:*'
>    dbr 1
>    ','&cutl;._2 csvfile
> |stop: cutl
> |   y=.y,x
> |cutl[:0]
>       y
> a,tkr,dt,s,td,l,cd,qu,pr,val,cst,ty,lgl,sgl,iq,iu,ix,qc,qp,st,dte,cq,qv,cmt
>       x
> ,
>
> From A+, I'm familiar with a function being applied to each element of an
> entity.
> What surprised me was that the code in cutl was being reinterpreted by the
> J-interpreter for each element.
> I guess that's because the the conjuction is applied to a defined
> function, and not a primitive.
>
>
> On Sun, Jan 8, 2012 at 5:06 PM, Ric Sherlock <tikk...@gmail.com> wrote:
>
>> To be precise cutl is being "fed" csvfile one record at a time by the
>> conjunction cut ( ;. ). ( cutl;._2 ) will chop its right argument into
>> bits using the last item of the right argument (probably a line-feed)
>> as the record delimiter (fret) and apply the verb u (in your case (
>> ','&cutl ) to each of those records.
>>
>> http://www.jsoftware.com/docs/help701/dictionary/d331.htm
>>
>> On Mon, Jan 9, 2012 at 6:50 AM, Tom Szczesny <tav...@gmail.com> wrote:
>> >
>> >    ',' &cutl;._2 csvfile
>> >
>> > I was amazed that  cutl  loops through csvfile one 'record' at a time,
>> > as none of the 9 control structure patterns listed in the Primer were
>> > evident.
>> >
>> >
>> >
>> > On Mon, Jan 2, 2012 at 12:44 PM, Joey K Tuttle <j...@qued.com> wrote:
>> >
>> >> I believe that there are a collection of csv related utilities in
>> addons
>> >> ( require 'csv' will make those available to you).
>> >>
>> >> However, for years I have used a simplistic verb to bring .csv files
>> >> into a j session as a table of enclosed values -
>> >>
>> >>    cutl =: 3 : 0
>> >> :
>> >>  y =. y,x
>> >>  q =. y e.'"'
>> >>  qs =. ~:/\q
>> >>  }.^: ('"'&=@([:{.1:{.]))&.> (qs<y e.x) <;._2&((q<:qs)&#) y
>> >> )
>> >>
>> >>    tablecsv =: 3 : 0
>> >>     ',' tablecsv y   NB. allows choosing an alternative delimiter
>> >> :
>> >>     x &cutl;._2 y
>> >> )
>> >>
>> >>
>> >> On 2012/01/02 09:22 , Tom Szczesny wrote:
>> >> > Some languages, like q, have a built-in command for reading,
>> parsing, and
>> >> > loading data from csv files:
>> >> >     t: ("SSDIDSSIFFFIS";enlist ",")  0: `:/home/tom/t.csv
>> >> >
>> >> > Other languages, like a+, do not, and the user needs to write a
>> function
>> >> to
>> >> > read, parse and load data from csv files.
>> >> >
>> >> > > From a cursory review, it appears that j is in the a+ camp.
>> >> > Please confirm that such a facility does not exist in j, before I
>> start
>> >> > writing my own.
>> >> >
>> >>
>> >> ----------------------------------------------------------------------
>> >> 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