Page 1 of 1

using ref data

Posted: Sun Aug 30, 2020 10:07 am
by joejoe
The ref and ref-all functions bring back an address or list of addresses.

As cormullion wrote in the nL wikibook:

Code: Select all

(ref-all "Brian Eno" itunes-data)
;-> ((0 2 14 528 6 1) (0 2 16 3186 6 1) (0 2 16 3226 6 1))
What would be the best way to get that data instead of the numerical addresses?

Essentially, once I find the address is (0 2 14 528 6 1), how best would I get what it actually is, not the address?

So how best to get (0 2 16 3186 6 1) data?

Thank you!

Re: using ref data

Posted: Mon Aug 31, 2020 1:38 pm
by newBert
Sorry, I don't have time to answer from a concrete example that should first be created. But I think there are some interesting tracks in the wikibook, especially here (see 'find-all' at the end).

Re: using ref data

Posted: Tue Sep 01, 2020 5:45 pm
by fdb
Hi joejoe ,

the best way to get the data would be to map over the results and use implicit indexing.

So ref-all would give you a list of indices, probably the data you're looking for is one level up in this structure, then I would do:

Code: Select all

(map (fn(x) (itunes-data (chop x))) (ref-all "Brian Eno" itunes-data))

Re: using ref data

Posted: Wed Sep 02, 2020 7:34 am
by cameyo
Hi joejoe,
the "ref-all" and "ref" functions have a parameter to get data instead of indexes.

Code: Select all

(setq lst '(a b c (d a f (a h a)) (k a (m n a) (x))))
(ref-all 'a lst)
;-> ((0) (3 1) (3 3 0) (3 3 2) (4 1) (4 2 2))
(ref-all 'a lst = true)
;-> (a a a a a a)
But maybe I misunderstood the question.
cameyo

Re: using ref data

Posted: Wed Sep 02, 2020 10:14 am
by newBert
cameyo wrote:
Wed Sep 02, 2020 7:34 am
the "ref-all" and "ref" functions have a parameter to get data instead of indexes.
Well seen ! I had completely forgotten this option.
Thanks, Cameyo.

Re: using ref data

Posted: Fri Sep 11, 2020 5:30 am
by joejoe
Thanks very much for all the exemplars!

ref and map seem to carry things out quite well!

Much appreciated!