Hello,
I'm new to Clojure and new here (if I'm missing something please point me
to it)
I'm trying to parse a lazy sequence of strings. After parsing, I'll create
key value pair which needs to be added to either one of the two maps.
I'm coming from Python background and having a tough time to get my mind
around immutable map data structure.
Here's Python-ish version of what I'm trying to do:
container1 = {}
container2 = {}
for line in myLazySeq:
if re.match(somePattern, line):
container1[key] = value # key and value are obtained from `line`
elif re.match(pattern2, line):
container2[key] = value
else:
# unrecognized input, discard
The program is multi threaded but these maps are thread local.
I searched and found `conj` and `assoc` which return a new map, which
suggests I may have to update my reference to the new map returned.
My question is, how should I 'add a new element to map'
As I said, I'm new to this, if I'm missing something very obvious please
point me to it.
To make my question more concrete, the lazy sequence is obtained by
applying `line-seq` to Java BufferedReader which in turn is obtained from a
socket.
I'm trying to make a simple HTTP server, and here I'm trying to parse
request sent over socket. If there a better way to do this please suggest
that too!
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
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
---
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 [email protected].
For more options, visit https://groups.google.com/d/optout.