Henry, Here's what seems strange to me.
f=: 13 :'(,:x)];.0 y'
f
] ];.0~ [: ,: [
5!:6 <'f'
] ((];.0)~) ([: ,: [)
4 5 (] (g=:(];.0)~) (B=:[: ,: [))A=:'abcdefghijk'
efghi
A
abcdefghijk
B
[: ,: [
]C=:4 5 B A
4 5
$C
1 2
g
];.0~
A g C
efghi
5!:4 <'g'
-- ]
-- ~ --- ;. -+- 0
h=: 13 :'x(];.0~)y'
h
];.0~
A h C
efghi
i=: 13 :'x((D=:]);.0~)y'
A i C
efghi
i
4 : 'x((D=:]);.0~)y'
type <'g'
-----┐
│verb│
L-----
type <'h'
-----┐
│verb│
L-----
type <'i'
-----┐
│verb│
L-----
When I write I and display I it begins 4 :
But when I ask for the type of I it is a verb.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Henry Rich
Sent: Thursday, April 10, 2014 9:01 PM
To: [email protected]
Subject: Re: [Jprogramming] "Segmented Strings"
Can anyone explain why
(,:3 4) ];.0 'abcdefghijklmnop'
defg
works?
According to Ye Dic, 0{x gives the starting point, and 1{x gives the
length. But
0 { (,:3 4)
3 4
1 { (,:3 4)
|index error
AFAICS a table with one row is treated as if it were a table with one
column.
In any case, to conform to the definition you should use
substr =: (];.0~ ,.)~"1 _
,. not ,:
Henry Rich
On 4/10/2014 8:23 PM, Don Guinn wrote:
> Yes. I used those for a long time. I think. ;. is faster.
> On Apr 10, 2014 6:06 PM, "Raul Miller" <[email protected]> wrote:
>
>> I'm going to be building hashes, but currently it looks like it'll be
>> faster to generate them after finding the unique values rather than
>> before.
>>
>> Hashes have great sales pitches in favor of them, but generating them
>> takes time.
>>
>> Meanwhile, getting lots and lots of real memory is relatively cheap.
>> According to https://aws.amazon.com/ec2/pricing/ I can use a machine
>> with 244 gigabytes of ram for $3.50 an hour. I do not think I'll need
>> that much memory, even for a short time.
>>
>> If it helps, though, there's other ways to get a substring:
>>
>> 4{.3}. 'abcdefghijk'
>> defg
>> (3+i.4){'abcdefghijk'
>> defg
>>
>> Thanks,
>>
>> --
>> Raul
>>
>>
>> On Thu, Apr 10, 2014 at 6:45 PM, Don Guinn <[email protected]> wrote:
>>>
>>>
>>> Sounds like you can format the data as you want once you get it all.
>> Given
>>> the amount of data there is no way to read it
>>> the entire file
>>> in an interactive environment. So it has to be indexed or in a
database.
>>> If you really want to use a segmented string you could keep the index to
>>> the start of each line to
>>> quickly get
>>> the line. Also, build a hash for the keys you intend to search on
rather
>>> than trying to search the actual file.
>>> This index and hash should fit in memory quite easily.
>>> When you talk about a file that big, mapped or not, it's still going to
>>> require the amount of virtual storage the size of the file, which will
>> need
>>> to be moved from the file or swap into real storage to process.
>>> Scanning the entire file
>>> will be very slow unless you have lots and lots of real memory.
>>>
>>> I haven't seen anyone mention an easy way to substring from a text file.
>> It
>>> took me a long time to find it in the dictionary.
>>> It really exists.
>>> And it was not obvious when I finally did find it. So I will post it
here
>>> for anyone who hasn't found it.
>>>
>>>
>>> substr=:4 : 0 NB. x: start and length, y: string
>>>
>>> (,:x)];.0 y
>>>
>>> )
>>>
>>> 3 4 substr 'abcdefghijk'
>>>
>>> defg
>>> ----------------------------------------------------------------------
>>> 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