Thanks Rob!

I did feel that the general idea of the rolling sum generating the indices of 
the frets was not terrible, it just seemed like I was doing too much work to 
get there.

I have noticed that almost every time I ask for something, it's right there in 
the core documentation!

> On Nov 16, 2017, at 10:20 PM, Rob Hodgkinson <[email protected]> wrote:
> 
> I meant to add … which is very close to what you derived.
> 
> The key is the generation of the fret, another way here, but the group may 
> suggest better phrases;
>     1(0,+/\}.20 10 12)}42$0
> 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
> 0 0 0
> 
> …/Regards Rob
> 
>> On 17 Nov 2017, at 4:03 pm, Rob Hodgkinson <[email protected]> wrote:
>> 
>> Hi Daniel, there is a primer article on cut (using cut2) which may help you;
>>      http://www.jsoftware.com/help/primer/cut.htm
>> 
>> The last example shows fixed width cuts using a boolean mask, so your same 
>> example could be generated as so;
>> 
>> NB. This generates the fret as a boolean list
>>      (i.42) e. +/\0,20 10 12
>> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 
>> 0 0 0 0
>> 
>> NB. Now apply the fret to the data using the ‘cut’ conjunction and argument 
>> is < (enclose)
>>     ((i.42) e. +/\0,20 10 12) <;.1 'John Smith WA 418-Y11-4111’
>> ┌────────────────────┬──────────┬────────────┐
>> │John Smith          │WA        │418-Y11-4111│
>> └────────────────────┴──────────┴────────────┘
>> 
>> NB. Now use rank “1 to apply the function on vectors of the table argument 
>> (as in your example) 
>>     ((i.42) e. +/\0,20 10 12) <;.1"(1) 1 42$'John Smith WA 418-Y11-4111’   
>> NB.
>> ┌────────────────────┬──────────┬────────────┐
>> │John Smith          │WA        │418-Y11-4111│
>> └────────────────────┴──────────┴────────────┘
>> 
>> Hope this helps, Regards Rob
>> 
>> 
>>> On 17 Nov 2017, at 3:36 pm, Daniel Lyons <[email protected]> wrote:
>>> 
>>> My problem is essentially to give an input file and the column widths and 
>>> get it split up properly. I asked about it on the code review stack 
>>> exchange site, but there doesn't seem to be much traffic there, so I 
>>> figured maybe I could get a few eyes without annoying too many people 
>>> reposting here.
>>> 
>>> https://codereview.stackexchange.com/questions/180633/parsing-fixed-width-format-with-j
>>>  
>>> <https://codereview.stackexchange.com/questions/180633/parsing-fixed-width-format-with-j>
>>> 
>>> The solution I hacked up is this:
>>> 
>>> parseFW =: dyad def '(+/ (0,+/\x) ="(0 1) i. (+/x)) <;.1 y'"(_ _1)
>>> 
>>> Usage then looks like this:
>>> 
>>> (20 10 12) parseFW  1 42 $ 'John Smith          WA        418-Y11-4111'
>>> 
>>> I find this works, at least for the simple cases I have thrown at it so 
>>> far, but I can't help but feel there's too much happening here for 
>>> something fairly simple. I know where the frets are the rest is just 
>>> encoding them. In particular it felt like the inverse of I. should be 
>>> helpful but I didn't get that working.
>>> 
>>> If there's a library that does this, I'd probably rather use that, but I 
>>> didn't see one at first blush.
>>> 
>>> Input greatly appreciated! Thanks,
>>> 
>>> -- 
>>> Daniel Lyons
>>> 
>>> 
>>> 
>>> 
>>> ----------------------------------------------------------------------
>>> 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

-- 
Daniel Lyons




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

Reply via email to