Question

I am having trouble getting the function fixed-point from Clojure-Contrib Graph to run. Admittedly the problem is trivial. I have tried to use the techniques shown in loading clojure-contrib but am still running into trouble.

Note: I am using Leiningin to start the REPL.

Here's the source code for fixed-point:

(defn fixed-point

"Repeatedly apply fun to data until (equal old-data new-data) returns true. If max iterations occur, it will throw an exception. Set max to nil for unlimited iterations."

[data fun max equal]
  (let [step (fn step [data idx]
           (when (and idx (= 0 idx))
             (throw (Exception. "Fixed point overflow")))
           (let [new-data (fun data)]
             (if (= data new-data)
               new-data
               (recur new-data (and idx (dec idx))))))]
          (step data max)))

I can't seem to get an output from this function besides "Fixed point overflow." Could somebody show an example that works.

Was it helpful?

Solution

clojure.contrib.graph has no active mantainer so was never migrated after 1.2 clojure.contrib mega split.

If you're still using Clojure 1.2 you should be able to make it work though, otherwise there's an alternative clj-graph here for 1.3, but has been quiet for a while.

You should check your project.clj anyway for:

  • Proper clojure version
  • Proper dependency declaration

If still having problems please paste exception here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top