Working through the examples...

39 views
Skip to first unread message

Kenneth Flak

unread,
Jan 11, 2024, 1:28:03 AMJan 11
to Overtone
Hi guys,

Starting to wrap my head around the wonderful world of clojure and SC, and stumbled upon a bug in the example code:

```
(defn foo-pause
  []
  (dotimes [i 10]
    (foo (* i 220) 1)
    (Thread/sleep 300)))
```

This will output a frequency of 0 at the first iteration. Yikes... Fix:

```
(defn foo-pause
  [basefreq]
  (dotimes [i 10]
    (foo (+ basefreq (* i basefreq)) 1)
    (println "foo-pause: " i)
    (Thread/sleep 300)))

(foo-pause 220)
```
or something to that effect? No idea if this would qualify as idiomatic clojure, though...

Kenneth Flak

unread,
Jan 11, 2024, 4:12:55 AMJan 11
to Overtone
Or, a bit more succinct:

(defn foo-pause
  [basefreq]
  (dotimes [i 10]
    (foo  (* (+ i 1) basefreq) 1)

    (println "foo-pause: " i)
    (Thread/sleep 300)))

Arne Brasseur

unread,
Jan 11, 2024, 4:13:50 AMJan 11
to Overtone
Good catch! a pull request to improve the examples is certainly welcome!

Kenneth Flak

unread,
Jan 11, 2024, 7:09:13 AMJan 11
to Overtone
will do as soon as I get a bit more time to do so :-)
Reply all
Reply to author
Forward
0 new messages