Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected output in the min-1 function in the clojure labs #22

Closed
cervatz opened this issue Jul 27, 2010 · 2 comments
Closed

unexpected output in the min-1 function in the clojure labs #22

cervatz opened this issue Jul 27, 2010 · 2 comments

Comments

@cervatz
Copy link

cervatz commented Jul 27, 2010

Unexpected output of the following function in the labs/looping page in the clojure labs web application

(defn min-1
[x & more](loop [min x
more %28seq more%29]
%28if-let [x %28first more%29]
%28recur %28if %28< x min%29 x min%29 %28next more%29%29
min%29))

I would expect it to return the minimum value of the vector, but it returns the whole vector.

I am a total beginner with clojure so I apologize for any stupid comment. But if this code really does not work maybe it is good to fix it, because many people might be trying to learn clojure with the labrepl clojure labs.

Thank you!

@stuarthalloway
Copy link
Member

Check the signature: min-1 doesn't take a vector, it takes a variable length sequence of args:

(min-1 1 -3 5) => -3

@cervatz
Copy link
Author

cervatz commented Jul 27, 2010

Thank you very much!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants