Hi people! Any way to produce a lazy seq of chars, that prints as a string, based on two parameters, n (number of repeats), text (text to repeat)?
Then, something like (myrepeat 1000000 "superdupertext") could be implemented without a big processing or concatenation. Angel "Java" Lopez http://www.ajlopez.com http://twitter.com/ajlopez On Mon, Jun 28, 2010 at 3:14 PM, Nurullah Akkaya <nurul...@nakkaya.com>wrote: > Hi José, > > user=> (apply str (repeat 3 "code")) > "codecodecode" > > will give you what you want, > if we break it down, > > user=> (repeat 3 "code") > ("code" "code" "code") > > repeat will give you a sequence of xs, > since you don't know the length of the > sequence at compile time we apply str > to the sequence > > (apply str '("code" "code" "code")) > > which basically expands to, > > (str "code" "code" "code") > > then you get, > > "codecodecode" > > > -- > Nurullah Akkaya > http://nakkaya.com > > > > 2010/6/27 José Luis Romero <tangu...@gmail.com>: > > Hi! I am learning the core of clojure, and so far, I am loving it. But > > I am not a lisp programmer (python, java, among others), but never > > functional programming. I am practicing with codingbat.com, coding the > > exercises on clojure. I am stuck with loops. I want to concatenate n > > times a string. For example, given the parameters 3 and "code" the > > output will be "codecodecode". How can I do a loop in order to get > > this output. > > > > I know that this is a very newb question, any help will be > > appreciated. > > > > -- > > 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<clojure%2bunsubscr...@googlegroups.com> > > For more options, visit this group at > > http://groups.google.com/group/clojure?hl=en > > > > -- > 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<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > -- 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