Hi all,

I came across an obscure behaviour in clojurescript.

The original function is used to tabulate, as a list of lists, "non 
overlapping sub-sequences".
I stripped out the unessential parts from my code to get the following.
It doesn't do anything specific - but exhibits similar behaviour

uncommenting the comment below causes the correct behaviour to be produced.
when commented the result is different
when commented, and if you count it, the length of 'held' increases 
indefinitely and the function does not terminate

(defn obscure-bug
  ([a-seq held iresult fresult]
    (if (empty? a-seq)
      (if (empty? held)
        (conj fresult iresult)
        (recur held [] [] (conj fresult iresult)))
      (let [[item & remainder] a-seq
            [n-held new-seq] (split-with (fn [i] (> item i)) remainder)
           
            ;;;; _x (doall n-held) ; <-- uncommenting this produces 
different results in clojurescript, it does not in clojure
            
            ]
        (recur new-seq (concat held n-held) (conj iresult item) fresult)
        ))))


(obscure-bug [1  7  8 9  6 2 3 4 5 6] [] [] [])

; in clojure - whether commented or not

[[1 7 8 9] [6 6] [2 3 4 5]]

; in clojurescript

; uncommented
[[1 7 8 9] [6 6] [2 3 4 5]]

; commented
[[1 7 8 9] [7] [6] [2]]


Regards

Dave

-- 
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

Reply via email to