[Haskell-cafe] replacement
Neil Mitchell
ndmitchell at gmail.com
Sat Apr 14 06:48:53 EDT 2007
Hi
> 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.
Is this homework? http://www.haskell.org/haskellwiki/Homework_help
> 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]]
If it is, use Lisp. Try assigning a type to this in Haskell, its not
particularly easy, and would require clever type class stuff.
Thanks
Neil
More information about the Haskell-Cafe
mailing list