[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-apl] String element of general array
From: |
David B. Lamkins |
Subject: |
Re: [Bug-apl] String element of general array |
Date: |
Sun, 11 May 2014 16:31:22 -0700 |
Um, yes and no.
This was all hacked together during compilation breaks while at work. I
didn't put any effort into testing edge cases.
In particular, I assumed string keys. I didn't design for or test with
numeric keys.
Also, `me' was designed as a helper for `nl'. In combination with `nl'
and for string keys, it's working as intended. You might be able to
combine `me' and `nl'.
Finally, I already pointed out the risk of 'a' 'b', which is identical
to 'ab'.
Set ]boxing 8 and run strings (and lists thereof) through `nl'. They
should all give you structures of depth 2. Remember that you'll need to
enclose or enlist character scalars if you intend to pass a list of same
to `nl'; that's an APL 2 feature that you can't program around.
On Sun, 2014-05-11 at 16:38 -0500, Blake McBride wrote:
> Is this what you intended of the 'me' function:
>
>
> ≡me 4
> 3
> ≡me 5 6
> 2
> ≡me ''
> 2
> ≡me 'f'
> 3
> ≡me 'ff'
> 2
> ≡me 'aaa' 'bbb'
> 3
> ≡me 'a' 'b'
> 2
>
>
>
>
> On Fri, May 9, 2014 at 4:00 PM, David B. Lamkins <address@hidden>
> wrote:
> Here's a version that doesn't use a lambda. Instead, there's a
> new
> function `findl' that captures `list' from its caller
> (`finds').
>
> ∇z←list find key
> z←key≡¨list
> ∇
>
>
> ∇z←findl key
> z←(nl list) find ⊂key
> ∇
>
> ∇z←list finds keys
> z←findl¨nl keys
> ∇
>
> ∇z←me e
> z←⊂(⎕io+≡e)⊃(⊂,e) (,e) (e)
> ∇
>
>
> ∇z←nl l
> z←me¨(⎕io+1=≡l)⊃l (⊂l)
> ∇
>
>
>
> On Fri, 2014-05-09 at 12:55 -0700, David B. Lamkins wrote:
>
> [snip]
>
> > Here's an example:
> >
> > ]boxing 8
> > ll←'a' 'bc' 'def' 'foo' 'g'
> > ll
> > ┌→───────────────────┐
> > │a ┌→─┐ ┌→──┐ ┌→──┐ g│
> > │ │bc│ │def│ │foo│ │
> > │ └──┘ └───┘ └───┘ │
> > └∊───────────────────┘
> > ll finds 'a'
> > ┌───────────┐
> > │┌→────────┐│
> > ││1 0 0 0 0││
> > │└─────────┘│
> > └∊──────────┘
> > ll finds 'bc' 'foo'
> > ┌→──────────────────────┐
> > │┌→────────┐ ┌→────────┐│
> > ││0 1 0 0 0│ │0 0 0 1 0││
> > │└─────────┘ └─────────┘│
> > └∊──────────────────────┘
> > ⍝ Beware...
> > ll finds 'a' 'g'
> > ┌───────────┐
> > │┌→────────┐│
> > ││0 0 0 0 0││
> > │└─────────┘│
> > └∊──────────┘
> > ⍝ ... because:
> > 'a' 'g'
> > ┌→─┐
> > │ag│
> > └──┘
> > ll finds (,'a') (,'g')
> > ┌→──────────────────────┐
> > │┌→────────┐ ┌→────────┐│
> > ││1 0 0 0 0│ │0 0 0 0 1││
> > │└─────────┘ └─────────┘│
> > └∊──────────────────────┘
> >
>
>
>
>
>
- Re: [Bug-apl] String element of general array, (continued)
- Re: [Bug-apl] String element of general array, Blake McBride, 2014/05/09
- Re: [Bug-apl] String element of general array, Elias Mårtenson, 2014/05/09
- Re: [Bug-apl] String element of general array, Blake McBride, 2014/05/09
- Re: [Bug-apl] String element of general array, David B. Lamkins, 2014/05/09
- Re: [Bug-apl] String element of general array, Blake McBride, 2014/05/09
- Re: [Bug-apl] String element of general array, David B. Lamkins, 2014/05/09
- Re: [Bug-apl] String element of general array, Blake McBride, 2014/05/09
- Re: [Bug-apl] String element of general array, David B. Lamkins, 2014/05/09
- Re: [Bug-apl] String element of general array, David B. Lamkins, 2014/05/09
- Re: [Bug-apl] String element of general array, Blake McBride, 2014/05/11
- Re: [Bug-apl] String element of general array,
David B. Lamkins <=