Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread 'Pascal Jasmin' via Programming
'ello' (<@[ +/@:= #@[ <\ ])'Hello Jello' will return the count of matches. On Friday, April 9, 2021, 09:48:11 a.m. EDT, Emir U wrote: s=: 'Hello Jello' Given a string like the above, I need to tabulate the number of occurrences of every letter for every prefix of length >=k. I also

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread xash
You can get every substring in a list with ; <@<\\. s If k is quite large, your approach with every k : #) <@<\ ] tab=: (<:@# ; }: ; {:)&> count=: ~. ,. <@#/.~ f=: count@:tab@:subs 4 f s -- For information about J

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread Emir U
Hey Mike, no prefixes don't have counts, letters with prefixes have counts. Your example: Hello Jello Hello Jello prefix length=8, prefix=llo Jell, letter=o, count=2 That's true for 'o' because 'o' follows both occurrences. Some more examples using your string. prefix length=1, prefix=l, lett

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread 'Michael Day' via Programming
Thanks - so in this slightly longer,  repetitive string: <<     s,' ',s Hello Jello Hello Jello >> 'llo Jell' would be a prefix (among several others!) with a count of two? (I see Julian has posted something which is probably useful...) Cheers, Mike On 09/04/2021 15:12, Emir U wrote: Hey Mi

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread Julian Fondren
/. gives you letter-tabulations and \ gets you prefixes: s=: 'Hello Jello' Given a string like the above, I need to tabulate the number of occurrences of every letter for every prefix of length >=k. I also need to know the length of the prefix. So: As an example, prefix length=3, prefi

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread Emir U
Hey Mike, many thanks for looking, its all just one string. There are no implicit delimiters in the string itself. Emir > Just in case it matters,  are you regarding Hello & Jello as distinct words > here,  or is space just another character? > If they're separate,  then we need only examine (;:

Re: [Jprogramming] String prefixes and tabulation

2021-04-09 Thread 'Michael Day' via Programming
Just in case it matters,  are you regarding Hello & Jello as distinct words here,  or is space just another character? If they're separate,  then we need only examine (;: s) or (cut s), brackets only to delimit the J idioms. Thanks, Mike On 09/04/2021 14:48, Emir U wrote: s=: 'Hello Jello'

[Jprogramming] String prefixes and tabulation

2021-04-09 Thread Emir U
s=: 'Hello Jello' Given a string like the above, I need to tabulate the number of occurrences of every letter for every prefix of length >=k. I also need to know the length of the prefix. So: As an example, prefix length=3, prefix=ell, letter=o, count=2 In my real use case k may be quite