using ref data

Started by joejoe, August 30, 2020, 03:07:07 AM

Previous topic - Next topic

joejoe

The ref and ref-all functions bring back an address or list of addresses.



As cormullion wrote in the nL wikibook:


(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

#1
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 https://en.wikibooks.org/wiki/Introduction_to_newLISP/Lists#Find_and_replace_matching_elements">here (see 'find-all' at the end).
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

fdb

#2
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:

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

cameyo

#3
Hi joejoe,

the "ref-all" and "ref" functions have a parameter to get data instead of indexes.
(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

#4
Quote from: cameyo post_id=24928 time=1599032047 user_id=732
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.
<r><I>>Bertrand<e></e></I> − <COLOR color=\"#808080\">><B>newLISP<e></e></B> v.10.7.6 64-bit <B>>on Linux<e></e></B> (<I>>Linux Mint 20.1<e></e></I>)<e></e></COLOR></r>

joejoe

#5
Thanks very much for all the exemplars!



ref and map seem to carry things out quite well!



Much appreciated!