[Cs254f11] Simple question - def and concat

Jesse French jaf10 at hampshire.edu
Wed Oct 19 11:16:16 EDT 2011


Hi all, very simple question related to this function:

(defn new-pop
  [popsize length]
  (loop [loopcount 1]
    (if (< loopcount popsize)
      (def melody (new-melody length))
      (recur (inc loopcount)))))

This works, but I'd like to def a different "melody (new-melody length)" each time. Basically, each run through the loop should create a unique melody with a unique name - my hope was to just name it 'melody' with the count appended.

My first thought was to do this:

      (def (concat "melody" (loopcount)  (new-melody length))

But I am running into problems each time I try a different way. One obvious problem is the different data types involved, but even if I pass it a working concat statement def will not accept a statement that begins this way.

Any ideas for getting around this?

Thanks,
Jesse



More information about the Cs254f11 mailing list