Help with clojure problem

Discussion of other Lisp dialects (Arc, Clojure, AutoLisp, XLISP, etc.)

Help with clojure problem

Postby steve1994 » Sat Nov 14, 2015 7:32 am

sd
Last edited by steve1994 on Sat Nov 14, 2015 2:25 pm, edited 1 time in total.
steve1994
 
Posts: 3
Joined: Sat Nov 14, 2015 7:30 am

Re: Help with clojure problem

Postby nuntius » Sat Nov 14, 2015 1:00 pm

This sounds like a recursive homework problem.

Write a recursive function.
When descending the tree,
- if the node is an integer, return it
- if the node is a list, take the operator, recurse into the children, then evaluate the operator, and return the evaluated list
When evaluating the operator, the evaluated argument nodes are either values or lists with the value in the first entry
User avatar
nuntius
 
Posts: 524
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: Help with clojure problem

Postby steve1994 » Sat Nov 14, 2015 1:22 pm

Hi thanks for your reply.

I'm a complete beginner at this and have no clue how to do any of that. There isn't really much material online to help figure this out. Any chance you could give me a bit more of a push in the right direction on how to do that?


Thanks,
steve1994
 
Posts: 3
Joined: Sat Nov 14, 2015 7:30 am

Re: Help with clojure problem

Postby steve1994 » Sat Nov 14, 2015 1:28 pm

from what you said ive got this:
its incomplete and doesnt work but i have no clue how to go about doing the rest

thanks

(defn evaltree [tree]
(cond (number? tree) tree)
(tree? tree)
(eval (evaltree))
steve1994
 
Posts: 3
Joined: Sat Nov 14, 2015 7:30 am

Re: Help with clojure problem

Postby nuntius » Sat Nov 14, 2015 6:37 pm

User avatar
nuntius
 
Posts: 524
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA


Return to Other Dialects

Who is online

Users browsing this forum: No registered users and 1 guest