Quickest 'replace on nested lists?
Posted: Fri Jun 01, 2007 9:29 pm
Im currently fighting an issue ;-)
(probably easy to fix but i dont see it..)
I have 2 lists..
'one = 30000 total entry's (single list)
'two = 1000000 total entry's (nested list, 30000 entry's with all 1 sub-list)
Now i want to replace all occeurences from list 'one in nested list 'two.
(everything, including the nested lists..thus 'ref-all if the choise here..)
When i do it like this its very very slow ->
(map (fn(q) (map (fn(r) (nth-set (two r) "-bye-")) (ref-all q two))) one)
(That is because of the nested 'map)
this is very quick ->
(map (fn(r) (nth-set (two r) "-bye-")) (ref-all "this one" two))
(single map, but only replacing 1 value "this one" instead of the whole 'one)
I dont want to use 'dolist because thats too slow..
I cant use replace-assoc because its not an assoc list.
I cant use 'replace because that cant handle imlpicet-indexing.
Also 'match and 'unify seem not to provide a solution, i could be wrong!
So is there a complete different way of replacing all values from 'one in a nested list 'two by doing it in a one-liner?
addon: both lists contain strings only.
addon 2: It must be destuctive because of memory usage
Norman.
(probably easy to fix but i dont see it..)
I have 2 lists..
'one = 30000 total entry's (single list)
'two = 1000000 total entry's (nested list, 30000 entry's with all 1 sub-list)
Now i want to replace all occeurences from list 'one in nested list 'two.
(everything, including the nested lists..thus 'ref-all if the choise here..)
When i do it like this its very very slow ->
(map (fn(q) (map (fn(r) (nth-set (two r) "-bye-")) (ref-all q two))) one)
(That is because of the nested 'map)
this is very quick ->
(map (fn(r) (nth-set (two r) "-bye-")) (ref-all "this one" two))
(single map, but only replacing 1 value "this one" instead of the whole 'one)
I dont want to use 'dolist because thats too slow..
I cant use replace-assoc because its not an assoc list.
I cant use 'replace because that cant handle imlpicet-indexing.
Also 'match and 'unify seem not to provide a solution, i could be wrong!
So is there a complete different way of replacing all values from 'one in a nested list 'two by doing it in a one-liner?
addon: both lists contain strings only.
addon 2: It must be destuctive because of memory usage
Norman.