On Sat, Oct 11, 2008 at 2:40 PM, R. P. Dillon <[EMAIL PROTECTED]> wrote: > > I was noticing that a lazy list seems to get forced as soon as you > create it on the Repl because printing it forces evaluation. (range 1 > 100), for example, produces: > > (1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 > 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 > 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 > 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 > 96 97 98 99) > > Coming from Scala, If you create something like Stream.range(1,100) on > Scala's Repl, you'll get something back along the lines of: > > res0: Stream[Int] = Stream(1, ?) > > The question mark indicates that there is more to the Stream that > hasn't yet been calculated. There are some other neat properties of > this. It also allows you to see how far a Stream has been forced. > Continuing from above: > > scala> res0.tail.head > res1: Int = 2 > scala> res0 > res2: Stream[Int] = Stream(1, 2, ?) > > Would Clojure benefit from having (repl-print) or (lazy-print) > function that would not force lazy lists? It could be activated by > default when on the Repl. >
I think one problem with that for Clojure is that virtually all of the sequence functions return lazy seqs and people often use them at the repl where they intend to see all of the results. There isn't a separate streams lib. Rich --~--~---------~--~----~------------~-------~--~----~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---