(time (do ((many anything) (range 1 5000)) nil))
(def many (parser) "Parser is repeated zero or more times." (fn (remaining) (many-r parser remaining (tconc-new) nil))) (def many-r (parser li acc act-acc) (iflet (parsed remaining actions) (parse parser li) (many-r parser remaining (lconc acc (copy parsed)) (if actions (join act-acc actions) act-acc)) (return (car acc) li act-acc)))
ed: Yes. act-acc, not (car act-acc).
(iflet (parsed . remaining) (parse parser remaining) ...) (def return (parsed remaining) (cons parsed remaining))
If the speed increase is that large on that testbench, it might very well be due to garbage collection.
This might be an interesting page for our problem here ^^
http://www.valuedlessons.com/2008/03/why-are-my-monads-so-sl...
-----
(def many-r (parser li acc act-acc) (iflet (parsed remaining actions) (parse parser li) (many-r parser remaining (lconc acc (copy parsed)) (if actions (join act-acc actions) act-acc)) (return (car acc) li (car act-acc))))
Personally I don't mind losing 'actions, it does seem that 'filt would be better ^^.
Hmm. Not sure where the slow down is now ^^
I've tried my "retval" suggestion and it's actually slower, not faster. So much for not creating new objects T.T;