Hi Bobby,

Thanks for the reply. It worked and my server is serving over HTTP 1.0!
Next step: HTTP 1.1

Regards,
Anurag

On Tuesday, 8 November 2016 08:58:57 UTC-5, Bobby Eickhoff wrote:
>
> Here are a few thoughts.
>
> This algorithm sounds like a fold, i.e. a reduction.  You're iterating 
> over a sequence while accumulating into a collection.  A collection of 
> collections, in this case.
>
> You're starting value for the fold might be this:
>
> {:first {}, :second {}}
>
> You're reducing function would consume each line, adding it into the above 
> map of maps.  Updating the map-of-maps might be done through something like 
> update or update-in:
>
> (update-in maps [:first] add-by-key-and-value line)
>
>
> Here add-by-key-and-value is a function that I've left undefined.  It 
> takes a single map and a line and adds that line by key and value.  (Since 
> the definition of key and value were omitted from the example, I've 
> delegated them to said function.)
>
> Hence, the whole thing might look like this (untested!):
>
> (defn _______ [lines]
>   (let [rf (fn [maps line]
>              (condp re-matches line
>                #"some-regex"    (update-in maps [:first] 
> add-by-key-and-value line)
>                #"another-regex" (update-in maps [:second] 
> add-by-key-and-value key line)))]
>     (reduce rf {:first {}, :second {}} lines)))
>
>
> P.S.  I'm using update-in here a bit unnecessarily.  update would work 
> perfectly fine, but I thought it would be better to show you the general 
> form which can update maps to any depth.
>

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