Hi all, I am looking for a function that gives me a lazy sequence from a simple key, value file. Keys are words at the beginning of a line. Value start after a key and can span multiple lines. Thus, a file looks something like:
key1 = value1 is there and continues key2 = new value key3 = value3 takes some more lines as well I have a simple python generator that does the dirty work for me: def readpairs(name): key = None value = None for line in file(name): line = line.strip() data = line.split("=") if len(data) == 2: if key is not None: yield key, value key, value = data[0], [data[1]] else: if key is None: raise Exception("no key here") value.append(line) if key is not None: yield key, value The nice thing about this code is that it hides the messy details of reading multiple lines and gives me a clean sequence of key, value pairs to work with. I would like to have the same thing in clojure. I just do not find a good solution. Do you have any idea? Thanks a lot. Ulrich -- 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