remove

Started by eddier, November 26, 2003, 07:54:08 AM

Previous topic - Next topic

eddier

I'm getting a segmentation fault on

(map (fn (x) (remove "n" (read-file x))) fnames)

If I leave out the (remove I don't get the segmentation fault. Some of the files have "r" and some don't.



Eddie

Lutz

#1
'remove' can only be used on lists. (read-file x) returns a string. Use 'replace' instead to remove 'r' in your files.



Of course 'remove' should not bomb on  a wrong arg-type, this is fixed in development version 7.3.10 now available in the development directory:



http://newlisp.org/download/development/">http://newlisp.org/download/development/





Lutz

eddier

#2
I wonder if (replace could replace (remove ?



Eddie

Lutz

#3
how would you do this syntactically? nil or () as a replacement expressions wouldn't work, replace would plug in a nil or a (), while for empty strings it is fine with "". Of course one could do:



(while (set 'pos (find exp lst)) (pop lst pos))



as a replacement for 'remove'?



Or another idea would be, if the replacement expression is missing, than 'replace' works like remove? and this would also work for strings?



Lutz

Lutz

#4
Just checked the last suggestion: 'replace' with out replacement expression works like 'remove', in the code and it would be pretty easy to implement. After throwing the old 'replace' away, this would save a little bit of code.



Lutz