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 f
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 wrote:
> Here's a version that doesn't use a lambda. Instead, there's a ne
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¨(⎕
This is a lot easier in Lisp. On the other hand, I've known Lisp for 40
years and am just now learning APL 2. I was pretty good at APL in the
`70s and `80s, but the nested arrays are new to me. I really ought to
read some of Dr. Brown's papers...
Anyhow, I think this ought to help:
∇z←list find k
Dear David,
I had a solution to the single key case a while ago (see prior messages).
My problem is handling one or more keys.
Thanks for the help!
Blake
On Fri, May 9, 2014 at 11:39 AM, David B. Lamkins wrote:
> That particular function is not designed to accept multiple keys.
>
>
> On Fri,
That particular function is not designed to accept multiple keys.
On Fri, 2014-05-09 at 11:34 -0500, Blake McBride wrote:
> Greetings,
>
>
> It doesn't work:
>
>
> m←'hello' 'there' 'how' 'are' 'you'
> m
> hello there how are you
>
>
> m find 'are'
> 0 0 0 1 0
> m
Greetings,
It doesn't work:
m←'hello' 'there' 'how' 'are' 'you'
m
hello there how are you
m find 'are'
0 0 0 1 0
m find 'are' 'hello'
0 0 0 0 0
'are' find m
0 0 0
Thanks.
Blake
On Fri, May 9, 2014 at 11:15 AM, David B. Lamkins wrote:
> Try this:
>
> ∇z←list fi
Try this:
∇z←list find key
z←(,¨list)∊⊂,key
∇
(Also: please trim your replies.)
On Fri, 2014-05-09 at 10:26 -0500, Blake McBride wrote:
> Interesting. I didn't know about ≡. That's helpful, but the issue
> you raise with 'a' 'b' leaves us back to where I started. There
> should be a simple w
Interesting. I didn't know about ≡. That's helpful, but the issue you
raise with 'a' 'b' leaves us back to where I started. There should be a
simple way for me to determine whether to do ⊂ or not. I just haven't
figured out how.
I read that there was a big debate about what ⊂ does on a scalar.
How would you do that? The problem here is that you as a person see 'foo'
and think of it as a string in this context and that you want to match on
it. However, the ∊ function sees an array of elements (those elements being
characters) so it acts upon them.
I suppose the best you can do would be t
Thanks for the tutorial. In my case, however, I already knew that. More
specifically, my problem is:
x←'hello' 'there' 'how' 'are' 'you'
∇r←test v
r←(⊂v)∊x
∇
This works for:
test 'there'
But doesn't work for:
test 'there' 'are'
I know I can remove the ⊂ for the second case. I need a sing
I was very confused about this when I started learning APL too (well
documented in this very mailing list's archive).
What happens can be illustrated by boxing the output. Let's look at a
string:
* 8⎕CR 'foo'*
┌→──┐
│foo│
└───┘
* ⍴'foo'*
3
In order words,this is a three-element array o
Greetings,
On Fri, May 9, 2014 at 12:10 AM, Daniel H. Leidisch wrote:
> Hello!
>
> Blake McBride
> writes:
>
> > x←'abcd' 'efg' 'hijkl'
> >
> > Now, if I have:
> >
> > y←'hijkl'
> >
> > z←'hhh'
> >
> > How can I tell if y is in x? How can I tell if z is in x?
>
> Or for both at once:
>
>
Thanks to all! Very cool! I feel comfortable creating, unpacking, and
moving general arrays, but that's the extent of it. I'll have to get some
of this new stuff in my head.
Thanks for the help!
Blake
On Fri, May 9, 2014 at 12:10 AM, Daniel H. Leidisch wrote:
> Hello!
>
> Blake McBride
>
Hello!
Blake McBride
writes:
> x←'abcd' 'efg' 'hijkl'
>
> Now, if I have:
>
> y←'hijkl'
>
> z←'hhh'
>
> How can I tell if y is in x? How can I tell if z is in x?
Or for both at once:
(y z)∊x
1 0
Regards,
Daniel
Hello!
Blake McBride
writes:
> x←'abcd' 'efg' 'hijkl'
>
> Now, if I have:
>
> y←'hijkl'
>
> z←'hhh'
>
> How can I tell if y is in x? How can I tell if z is in x?
(⊂y)∊x
Regards,
Daniel
And of course, it can be made generic using ¨:
* x ← 'foo' 'bar' 'this' 'is' 'a' 'list' 'of' 'strings'*
* x ≡¨ ⊂'bar'*
0 1 0 0 0 0 0 0
Regards,
Elias
On 9 May 2014 13:35, David B. Lamkins wrote:
> The outer product approach is APL 1.
>
> In APL 2, you can enclose the search term and
The outer product approach is APL 1.
In APL 2, you can enclose the search term and test for membership in the
list:
ll←'abd' 'defgh' 'ij' 'klm'
ll∊⊂'ij'
0 0 1 0
ll∊⊂'foo'
0 0 0 0
On Thu, 2014-05-08 at 22:56 -0500, Blake McBride wrote:
> Forgive the question, but my experience
It's easier than that. Your solution is:
*∨/ (⊂'bar') ⍷ x*
This is because X⍷Y returns a list of the elements of X that matches Y.
Then ∨/ is just a reduction of that.
Regards,
Elias
On 9 May 2014 11:56, Blake McBride wrote:
> Forgive the question, but my experience is only with the or
19 matches
Mail list logo