using ref data

Q&A's, tips, howto's
Locked
joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

using ref data

Post 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!

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Re: using ref data

Post 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).
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

fdb
Posts: 66
Joined: Sat Nov 09, 2013 8:49 pm

Re: using ref data

Post 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))

cameyo
Posts: 183
Joined: Sun Mar 27, 2011 3:07 pm
Location: Italy
Contact:

Re: using ref data

Post 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

newBert
Posts: 156
Joined: Fri Oct 28, 2005 5:33 pm
Location: France

Re: using ref data

Post 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.
BertrandnewLISP v.10.7.6 64-bit on Linux (Linux Mint 20.1)

joejoe
Posts: 173
Joined: Thu Jun 25, 2009 5:09 pm
Location: Denver, USA

Re: using ref data

Post by joejoe »

Thanks very much for all the exemplars!

ref and map seem to carry things out quite well!

Much appreciated!

Locked