My guess is that you're running into the discrepancy between map key equality and Clojure's "=".
Because Clojure's collections implement the Java Collection interfaces, they are required to test keys with Java's ".equals", and use a hash function that matches. Java defines a particular semantics for equality, which does not include the fancy numeric comparisons that "=" does. user> (= 1 1.0) true user> (.equals 1 1.0) false Thus, user> ((hash-map 1 "found") 1) "found" user> ((hash-map 1 "found") 1.0) nil Perhaps your function is returning a Ratio, BigDecimal, etc., whereas your map keys are Doubles. You can check like: user> (class (/ 1 10)) clojure.lang.Ratio The solution to your problem is likely (normality-table (double (some-function-that-evaluates-to 0.05))) Cheers, Jason On Jul 20, 8:27 am, Fabio Leimgruber <fabio.leimgru...@web.de> wrote: > Hello everyone, > > I am new to this mailing-list and to clojure. > > I use Stuart Halloway's 'Programming Clojure' as learning material and > reference. > While working on a rewrite of one of my old Common Lisp programs, I > ran into this strange problem: > > I want to compute some probabilities concerning the Gaussian > distribution. A map contains the pre-computed values for the > Integration. For example, one map-entry is 0.05 0.51994. The map is > called normality-table. The following works: > > user> (normality-table 0.05) > --> 0.51994 > > But when I want to wrap this lookup into a function and use an > expression a la > > (normality-table (some-function-that-evaluates-to 0.05)) > > the return value is nil, i.e. no matching key found. I checked the > function that returns the lookup key. It works correctly. > > Why does the lookup fail when the key is generated by a function? Is > there a better way to do this? > > Comments and Ideas are very much appreciated! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---