[Haskell-cafe] replacement
hossein rohani
hosseinerohani at yahoo.com
Sat Apr 14 04:00:30 EDT 2007
Write a function with three parameters, two atoms and a list, (say p1, p2 and L) that returns the list, L, with all occurrences of the first given atom, p1, replaced by the second one, p2. If P2 be nil, the given atom should be deleted and the returned list cannot contain anything in place of it, no matter how deep it occurred in the list.
Note: Remember it says that "no matter how deep it occurred in the list.".It means thatwe may have nested list
example: replace 1 2 [1 2 3 4] => [2 2 3 4]
replace 1 2 [[1 2 3][3 4 5 1]] => [[2 2 3][3 4 5 1]]
---------------------------------
Ahhh...imagining that irresistible "new car" smell?
Check outnew cars at Yahoo! Autos.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20070414/07e28e13/attachment.htm
More information about the Haskell-Cafe
mailing list