I am still having difficulties with this, so let me clarify by showing some 
sample code.


My fn looks like this:

(defn report [text]

(str
 "string1"
 "string2"
(apply str (map-indexed (fn [idx itm] (time-text idx itm)) (filtered-list 
text))))))

 

When I invoke spit in order to output a text file using the above funtion, 
I only get the first item in my list (filtered-list text) outputted

Here is the basic code for my fns used above:


(defn filtered-list [text]
(let
    [street (:str (address text))
     city (:city (address text))
     state (:state (address text))

;actually there's a bunch of other bindings, 3 will suffice for the example

]

  (remove nil?
          (conj '()   
                
                (if-not
                    (blank? street)
                  (str "ADDRESS: " street))
                (if-not
                    (blank? city)
                  (str "CITY: " city))
                (if-not
                    (blank? state)
                  (str "STATE: " state))))))


(defn time-text [time-idx text-var]
 (str some-string (hour-min time-idx) another-string)) 

;this uses the clojure time library
(defn hour-min [idx]
(format-local-time (plus (local-now) (minutes idx)) :hour-minute-second))
On Tuesday, July 8, 2014 2:28:52 AM UTC-7, Lee wrote:

>
> Sometimes you have to manually stamp out laziness, for this among other 
> reasons. 
>
> In some cases I apply the list function to do this: 
>
> => (str (map inc (range 10))) 
> "clojure.lang.LazySeq@c5d38b66" 
>
> => (str (apply list (map inc (range 10)))) 
> "(1 2 3 4 5 6 7 8 9 10)" 
>
>  -Lee 
>
>
> > On 8 July 2014 09:49, Glen Rubin <rubi...@gmail.com <javascript:>> 
> wrote: 
> > my-fn takes a number and a string as argument and outputs a string.  I 
> am using map-indexed and my-fn to comprehend a list of items with numbered 
> index as follows, 
> >   
> >   
> > (map-indexed (fn [idx itm]  (my-fn idx itm)) '(list-of-crap)) 
> >   
> > When i run this on the repl everything works well and I get a single 
> long string of output. But, I am trying to use the output of this function 
> in a report and it is not working in that context. 
> >   
> > The code to generate report looks something like this: 
> >   
> >  (str 
> >       string1 
> >       string2 
> >       string3 
> >     (map-indexed (fn [idx itm] (my-fn idx itm)) '(listofcrap)) 
> >       string4....etc... 
> > ) 
> >   
> > The code above will just print out 'clojure-lazy-seq' instead of the 
> string output.  If I try: 
> >   
> > (apply str  (map-indexed (fn [idx itm] (my-fn idx itm)) '(listofcrap))) 
> >   
> > Then I get the last item from my list properly formated in the report, 
> but that's all.  How do I print out everything?  Thanks 
> > 
>
>

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to