0

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.

Community
  • 1
  • 1
sunspots
  • 1,047
  • 13
  • 29
  • What do you mean by "trouble". That's pretty vague. We need more details, such as an exception. – Nathan Davis Nov 23 '13 at 19:48
  • I'm trying to write a function using fixed-point in a text editor, then run the function in the REPL. But am unsure if Graph requires a dependency, or use of Maven... – sunspots Nov 23 '13 at 19:57
  • @Alex How are you starting the REPL? Are you using the command line and setting the classpath manually or using leiningen? Please edit the answer and include the steps you are following to start the REPL so that we can help you. – juan.facorro Nov 24 '13 at 01:37

1 Answers1

1

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.

guilespi
  • 4,672
  • 1
  • 15
  • 24