Replace heads function in Lisp

Hello All,
I have recently started learning Lisp and currently I am struggling to design a function replace-heads, which takes a list-of-lists as one argument and an atom as the second, and returns a list-of-lists in which the first element of each component list has been replaced with the atom passed in. So, for example, (replace-heads '((a b c) (d e) (f g h)) 'x) returns ((x b c) (x e) (x g h)).

I am not able to apply tree recursion method when actually replacing the first element in the last sub list for a given parent node.

Can somebody please help?


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Yes, you can find help for that kind of problem.

Not here, but you can.

The usenet lisp and scheme newsgroups are good for this kind of thing. People will help make sure you aren't just cheating on your homework but, if you are sincere in asking for help, there's like a 60% or greater chance that someone will say something helpful that you can decipher if you are earnestly attentive. It's deliberately not an efficient way to get help -- only an effective one when it clearly makes sense. Meanwhile, talk to your TA.

(I don't officially speak for this site or even informally speak for this site. I'm just clueful enough to tell you what you oughta know.)