2010/11/24 cej38 <junkerme...@gmail.com>: > 5. ease of changing function calls to allow for extra stuff/ > functionality without breaking other stuff. An example would be best > here. Suppose I had defined some function that worked for a specific > purpose: > > (defn setzero [value] > "If value is less than 1.0E-8 setzero returns zero.." > (if (tolerance? value 1.0E-8) 0 value)) > > and later I decided that I would really like to use that same function > again, but that 1.0E-8 won't work in this new case. I can change > setzero so that it will work with all of my old code (without change > to the old code) but I can make it work new code as well. > > (defn setzero > "If value is less than parameter setzero returns zero. If no > parameter is specified, the default value of 1.0E-8 is used." > ([value] > (setzero value 1.0E-8)) > ([value parameter] > (if (tolerance? value 1.0E-8) 0 parameter)))
You mean this I suppose: (defn setzero "If value is less than parameter setzero returns zero. If no parameter is specified, the default value of 1.0E-8 is used." ([value] (setzero value 1.0E-8)) ([value parameter] (if (tolerance? value parameter) 0 value))) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en