Re: What I'm missing in my Instaparse rules?

2016-06-13 Thread Hussein B.
Oh my ... You saved my hair! :) Thanks a lot for your help and time. On Monday, June 13, 2016 at 12:03:54 PM UTC+2, puzzler wrote: > > Looks like you left off a + in your regular expression for String. > > On Mon, Jun 13, 2016 at 2:59 AM, Hussein B. <hubag...@gmail.com > &g

Re: What I'm missing in my Instaparse rules?

2016-06-13 Thread Hussein B.
ot;]+" "Harden }") > ("Harden }") > > A solution would be to make the regex for ITEM more restrictive. > > On Sun, Jun 12, 2016 at 12:52 PM, Hussein B. <hubag...@gmail.com > > wrote: > >> Hello, >> >> I'm playing around In

What I'm missing in my Instaparse rules?

2016-06-12 Thread Hussein B.
Hello, I'm playing around Instaparse library, starting very simple. For input like : { player } I created the following parser: (def ast (ist/parser "TEST = OBJECT = <#'\\s+'> = <'{'> = <'}'> ITEM = #'[^\"]+' OBJECT = CURLY_OPEN WHITESPACE* ITEM WHITESPACE*

Re: My Zipper isn't deleting what I thought is going to delete

2015-08-27 Thread Hussein B.
#(get % children) #(get % children) (fn [p c] (assoc p children c)) {children z}) looks like it'll do the right thing here. Take care, Moe On Thu, Aug 27, 2015 at 11:03 AM, Hussein B. hubag...@gmail.com javascript: wrote: The modify function (defn modify [loc] (- loc z

My Zipper isn't deleting what I thought is going to delete

2015-08-27 Thread Hussein B.
Hi, I'm trying to remove an element from nested data structure (nesting in unknown, so I'm trying to come up with a generic solution: (def z [ {a {b 1 c 2} children [{a {b 3 c 4} children []}]} {a {b 5 c 6} children []}

Re: My Zipper isn't deleting what I thought is going to delete

2015-08-27 Thread Hussein B.
The modify function (defn modify [loc] (- loc z/remove)) On Thursday, August 27, 2015 at 11:58:31 AM UTC+2, Hussein B. wrote: Hi, I'm trying to remove an element from nested data structure (nesting in unknown, so I'm trying to come up with a generic solution: (def z [ {a {b

How to move an element within a vector?

2015-08-25 Thread Hussein B.
Hi, For a vector like [A B C D E], how to remove an element to a specific location? For example [A D B C E] ? I thought about converting the vector into array but I would feel bad if I did that. What would be the idiomatic way to do that in Clojure? Thanks for help and time. -- You

Re: Why I'm getting NPE with zipper/next?

2015-08-24 Thread Hussein B.
Oh, I defined my zipper as: (def loz (z/zipper #(contains? % children) #(get % children) (fn [_ x ] x) {children z})) But is throwing an exception. This one works: (def loz (z/zipper #(get % children) #(get % children) (fn [_ x ] x) {children z})) On Monday, August 24, 2015 at 4:08:17

Re: Why I'm getting NPE with zipper/next?

2015-08-24 Thread Hussein B.
Hi Moi, Thanks a lot for your patience and help. I tried this so far: (defn edit-parents [editable? edit loc] (loop [loc loc] (if (z/end? loc) (z/root loc) (if (editable? (z/node loc)) (recur (- loc z/up (z/edit edit) z/up z/next)) (recur (z/next loc))

Re: Why I'm getting NPE with zipper/next?

2015-08-24 Thread Hussein B.
The result now is as desired: ({a {b 1, c 2}, children [{a {b 3, c 4}, children []}]} {a {b 5, c 6}, children []} {a {b 7, c 8}, children ({a {b 10, c 10}, children []} {a {b 9, c 10}, children []})}) But now the updated children is using list notation, not vector. Is it ok or it is for

Re: Why I'm getting NPE with zipper/next?

2015-08-24 Thread Hussein B.
a lot for your time and your helpful answers. Now I started to understand zippers, thanks to you. On Monday, August 24, 2015 at 7:36:17 PM UTC+2, Moe Aboulkheir wrote: Hussein, On Mon, Aug 24, 2015 at 5:40 PM, Hussein B. hubag...@gmail.com javascript: wrote: But now the updated

Re: Why I'm getting NPE with zipper/next?

2015-08-24 Thread Hussein B.
the branch? test (contains? % children). You could certainly extend the zipper to cover both cases, but there may well be a more compact way to accomplish your goal. What do you want to do with the piece of data? Take care, Moe On Fri, Aug 21, 2015 at 5:57 PM, Hussein B. hubag

Why I'm getting NPE with zipper/next?

2015-08-21 Thread Hussein B.
Hi, I have this structure: (def s [{n {id a} d 2 children [{n {id c} d 4 children []}]} {n {id b} d 3 children []}]) And I wrote a function with zippers to traverse it: (defn traverse [col] (loop [z col] (if (= (z/next z) z) z (if (z/branch? z) (recur (z/next z))

Re: Why I'm getting NPE with zipper/next?

2015-08-21 Thread Hussein B.
, Hussein B. hubag...@gmail.com javascript: wrote: Hi, I have this structure: (def s [{n {id a} d 2 children [{n {id c} d 4 children []}]} {n {id b} d 3 children []}]) And I wrote a function with zippers to traverse it: (defn traverse [col] (loop [z col

Re: How can find something inside heavily nested data structure ?

2015-08-21 Thread Hussein B.
Yes, that does the job. Thanks for your help and time. On Thursday, August 20, 2015 at 12:21:47 AM UTC+2, Alan Forrester wrote: On 19 Aug 2015, at 18:08, Hussein B. hubag...@gmail.com javascript: wrote: Here is more concrete example (def s [{n {id a} d 2 children [{n {id c} d 4

Re: Why I'm getting NPE with zipper/next?

2015-08-21 Thread Hussein B.
, may not be as convenient as you're imagining. https://clojuredocs.org/clojure.zip/zipper has helpful examples in it. Take care, Moe On Fri, Aug 21, 2015 at 5:06 PM, Hussein B. hubag...@gmail.com javascript: wrote: Hi, I changed println to z/node , this time I'm getting

How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
Hi, I have transformed JSON response into the equivalent data structure using Cheshire library. The result is a huge nested data structure , mostly vectors and maps. It is actually a tree. How to find a property that is nested deep inside the tree ? For example I'm search for the node that

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
and maps)? On 19 August 2015 at 17:26, Andy- andre...@gmail.com javascript: wrote: I have yet to evaluate it myself but this might do help you: https://github.com/nathanmarz/specter On Wednesday, August 19, 2015 at 10:18:06 AM UTC-4, Hussein B. wrote: Hi, I have

Re: How can find something inside heavily nested data structure ?

2015-08-19 Thread Hussein B.
: I have yet to evaluate it myself but this might do help you: https://github.com/nathanmarz/specter On Wednesday, August 19, 2015 at 10:18:06 AM UTC-4, Hussein B. wrote: Hi, I have transformed JSON response into the equivalent data structure using Cheshire library

How to transform this structure idiomaticlly in Clojure?

2015-08-18 Thread Hussein B.
Hi, I have the following structure. Node has a string properly and a vector nodes and of course, each node has a string a property and a vector of nodes. So I created the following record: (defrecord Node [title childs]) And I have the following JSON response: node string [ node1 [

As framework creator, how would you get user defined specific functions/macros?

2014-11-20 Thread Hussein B.
Hi, Lets say that you are framework creator and to use your framework, you defined a macro called defcontroller where the users of your framework add their logic. You -as framework creator- how would you load user defined source code files and collect their defcontroller definitions? Thanks

Re: Understanding how a collection reduce itself

2014-10-09 Thread Hussein B.
it a little nicer to use, but the mechanics are more or less the same. - James On 24 September 2014 15:30, Hussein B. hubag...@gmail.com javascript: wrote: To elaborate more, I know that with reducers, map for example isn't going to create the resulting sequence by using cons. That is clear to me

Re: Understanding how a collection reduce itself

2014-09-24 Thread Hussein B.
When the collection is reducing itself, it is going to create a sequence and call cons, conj or something like. If this is true, then I'm not sure what reducers is bringing to the table. Because according to what I read, by using reducers, map/filter functions aren't going to create and allocate

Re: Understanding how a collection reduce itself

2014-09-24 Thread Hussein B.
To elaborate more, I know that with reducers, map for example isn't going to create the resulting sequence by using cons. That is clear to me. But, if the collections is going to call cons while reducing itself, then I'm not sure what is the benefit of reducers (besides it makes sense and makes

Understanding how a collection reduce itself

2014-09-23 Thread Hussein B.
Hi, I spent a considerable time trying to understand reducers. I got the concept of how the map/filter function will return a function and it is not going to iterate over a sequence and it is not going to create a new sequence. The missing part though, who is creating the sequence? They say a

How to know if an agent throw an exception?

2014-06-20 Thread Hussein B.
Hi, When using send-off of an Agent, how to know if any exception is happened? Since AFAIK, agents are executed in different thread. Currently, I'm calling (agent-error) but nothing is logged. Maybe nothing went wrong but some how I'm sure something went wrong. Thank you. -- You received

How to tackle this concurrency problem?

2014-06-20 Thread Hussein B.
Hi, I have a ref that saves the ID of last processed event. Of course, I'm using Clojure STM facility. The problem now is I can't control the value of the ref. Due massive concurrency, it is updated and my logic is broken. How to guard, and really guard the update of that ref? Should I do

When to use (ensue) ?

2014-06-19 Thread Hussein B.
Hi, When dealing with Clojure ref types, when to use (ensure) ? 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

How to add elements to a vector that is the value of a map key?

2014-06-17 Thread Hussein B.
Hi, This is a very basic question, so be patient please! :) I have an empty map where key is an integer and the value is a vector. How I can add an element to the vector of a specific key? For example: {1 [11]} Then {1 [ 11 22]} Thanks for help and time. -- You received this message

Re: How to add elements to a vector that is the value of a map key?

2014-06-17 Thread Hussein B.
the value to the existing vector. On Tuesday, June 17, 2014 7:21:43 PM UTC+2, Hussein B. wrote: Hi, This is a very basic question, so be patient please! :) I have an empty map where key is an integer and the value is a vector. How I can add an element to the vector of a specific key

Re: How to add elements to a vector that is the value of a map key?

2014-06-17 Thread Hussein B.
Thanks, it works. In case, my initial map is a ref type (def m (ref { } )) Why this isn't working? (dosync (alter m #(update-in @v [1] (fnil conj [ ])) 11)) On Tuesday, June 17, 2014 7:55:14 PM UTC+2, Mauricio Aldazosa wrote: For updating the value of a map given a key you can use

Re: How to add elements to a vector that is the value of a map key?

2014-06-17 Thread Hussein B.
Oh, this works (dosync (alter v #(update-in %1 [1] (fnil conj [ ]) %2) 33)) On Tuesday, June 17, 2014 8:05:10 PM UTC+2, Hussein B. wrote: Thanks, it works. In case, my initial map is a ref type (def m (ref { } )) Why this isn't working? (dosync (alter m #(update-in @v [1] (fnil

Re: How to add elements to a vector that is the value of a map key?

2014-06-17 Thread Hussein B.
Nice! :) Thanks all for help. On Tuesday, June 17, 2014 9:00:06 PM UTC+2, Thomas Heller wrote: On Tuesday, June 17, 2014 8:16:36 PM UTC+2, Hussein B. wrote: Oh, this works (dosync (alter v #(update-in %1 [1] (fnil conj [ ]) %2) 33)) Not sure what %2 or 33 are doing there but you can

Doing Socket IO inside STM transaction

2014-06-17 Thread Hussein B.
Hi, I have a ServerSocket that stores the client ID and the client socket object into a ref type. And I also have a thread that is running in the background that checks if a specific condition is met, then it will start send notifications to the clients (it will use the client-id-ref and

Re: Doing Socket IO inside STM transaction

2014-06-17 Thread Hussein B.
17, 2014 11:45:52 PM UTC+2, Gary Trakhman wrote: Agent send operations inside a transaction get queued up and don't actually get sent until the transaction commits, that's probably what you want, it's meant for side-effects. On Tue, Jun 17, 2014 at 5:43 PM, Hussein B. hubag...@gmail.com

Re: Doing Socket IO inside STM transaction

2014-06-17 Thread Hussein B.
it looks from STM. 2 agents will have 2 independent queues, even though they might share threadpools, if you want to guarantee order, you need one queue. On Tue, Jun 17, 2014 at 5:54 PM, Hussein B. hubag...@gmail.com javascript: wrote: I think send-off is used for IO operations

How to unit test (defn-) functions?

2014-06-12 Thread Hussein B.
Hi, I like to use (defn-) when it comes to internal implementation functions. But since they aren't exposed, how to unit test them? Of course, I'm using Lein and clojure.test Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this

Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Hussein B.
Thanks. Now, I have a clue how to skip some posts here. On Thursday, June 12, 2014 3:41:13 PM UTC+2, Divyansh Prakash wrote: I compare Clojure to acid in this http://pizzaforthought.blogspot.in/2014/06/clojurelisp-lsdmeditation.html rant. -- You received this message because you are

How to iterate over maps and drop one specific element each time?

2014-06-11 Thread Hussein B.
Hi, I have a seq of maps: [ {:op :e :v 1} {:op :n :b 2} {:op :m :z 2.3} ] How to iterate over the sequence and extracting only the non-op entries? Desired result is: [ {:v 1} {:b 2} {:z 2.3} ] Thanks for help and time. -- You received this message because you are subscribed to the Google

What is going wrong in my code?

2014-05-11 Thread Hussein B.
Hi, I'm trying to learn how to make DSL in Clojure and Korma project is a really good place to learn from. I'm trying this very simple stuff (inspired by Korma, not Korma code): (def predicates {'and :and 'or :or 'not :not ' :gt

How to convert this list into map?

2014-05-10 Thread Hussein B.
Hi, I have this list: (:= :language Clojure) And I want to convert it to the following map data structure: {:op := , :language Clojure} I can't really think of a clear way how to do it. Would you please help? Thanks for help and time. -- You received this message because you are

Re: How to convert this list into map?

2014-05-10 Thread Hussein B.
That is beautiful! Thanks a lot! On Sunday, May 11, 2014 12:33:51 AM UTC+2, Mike Fikes wrote: Here is how you can derive that expression: {:op :=, :language Clojure} is the same as (hash-map :op := :language Clojure) which is the same as (apply hash-map '(:op := :language Clojure))

In Lein, is it possible to run a specific test suite?

2014-05-06 Thread Hussein B.
Hi, I'm using clojure.test and Lein. Is it possible to run a specific test suit ? I don't want to run the whole test each time. Thanks for help and time. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Why this Clojure part is working in Korma and no exception is thrown?

2014-04-21 Thread Hussein B.
Hi, I'm trying to study the source code of Korma project. (insert users (values {:first john :last doe})) This will resolve to (defmacro insert) https://github.com/korma/Korma/blob/master/src/korma/core.clj#L143 Will call (defn- make-query-then-execute)

Idiomatic Clojure for iterating all items of a map

2014-04-21 Thread Hussein B.
Hi, For a data structure such as: (def langs {:langs [ {:lang Clojure :version 1.6} {:lang Erlang :version 17} ] } ) How to iterate all the items of the maps? I tried this but it is too imperative to me: (doseq [lang (:langs langs) (doseq [k (keys lang)]

Dealing with edn for the first time

2014-04-20 Thread Hussein B.
Hi, I want to save the configuration of my application in edn file. Lein is used (of course). I want to pub my config.edn under /resources directory. But honestly, I don't know the format of edn. I tried to google it, but I didn't get anything helpful. The format is in its early stages. So,

Why (eval (list (quote (println Clojure)))) is throwing a Null Pointer Exception?

2013-08-24 Thread Hussein B.
Hi, Why the following snippet: (eval (list (quote (println Clojure is throwing a null pointer exception? Thanks for help and time. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: Entwined STM V1.0

2013-08-18 Thread Hussein B.
Great ! Congratulations! How it does compare with Clojure's builtin STM? Thanks. On Sunday, August 18, 2013 10:24:48 AM UTC+2, Ivan Koblik wrote: Hi All, Almost 4 years ago I developed STM with semantic concurrency control for my project at CERN. Main feature of this STM is the

Help to morph this imperative snippet into a functional one

2013-08-18 Thread Hussein B.
Hi! Would you please help me transforming this imperative code into functional one? The code is a typical snippet in imperative style. A lot of mutations that I don't even know how to start morphing it to Clojure. class Container { MapString, Container children; String letter;

Re: Help to morph this imperative snippet into a functional one

2013-08-18 Thread Hussein B.
. On Sunday, August 18, 2013 4:27:43 PM UTC+2, Chris Ford wrote: Can you explain what the code is supposed to do in English? Java is a little hard to read. :-) Are you doing Huffman coding or similar? On 18 August 2013 16:51, Hussein B. hubag...@gmail.com javascript:wrote: Hi! Would you

Help to start creating this DSL in Clojure

2013-08-17 Thread Hussein B.
Hi, I'm trying to create this Domain Specific Language: (query clojure (directory /usr/texts) (group-by :creation-date)) What it should do is to search for all files in a specific directory using a regexp and then group the result by some of files attributes. The idea is the

Re: [ANN] Pedestal-app Tutorial has been released

2013-07-09 Thread Hussein B.
O, Yeah! Thanks! On Tuesday, July 9, 2013 6:03:58 PM UTC+2, Ryan Neufeld wrote: Hey there, Clojurians/Pedestallions! I'm pleased to announce the release of a comprehensive tutorial for pedestal-app: http://bit.ly/pedestal-app-tutorial. In this tutorial we finally *dive deep* into the

How core.async compares to agents, future and promise?

2013-07-04 Thread Hussein B.
Hi, How core.async compares to agents, future and promise? When to use core.async and when to use agents, future and promise? Thanks for help and time. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

How to implement a distributed and concurrent system in Clojure?

2013-07-03 Thread Hussein B.
Hi, I read recently on the internet that Clojure concurrency tools make it easy to implement a highly concurrent system but on a single machine. But how to implement a highly concurrent system that runs on a multiple machines? Erlang, Elixir and Scala have the Actors model. Please correct me

Is it possible to parameterize proxy macro with defmacro?

2013-06-23 Thread Hussein B.
Hi, After I got your help last week to get my Macro working :) I tried to expand it more: I'm trying to parameterizing my object creation (I'm using clojure.core.match). Source class offers multiple constructors: (defmacro source [source-name constructor-args meths] (match

Re: Clojure in production

2013-06-19 Thread Hussein B.
I mentioned that! :D On Wednesday, June 19, 2013 9:40:57 AM UTC+2, Florian Over wrote: Hi, we at doo.net are using clojure and clojurescript for all our backend and web development. We are also still in need for clojure developers. :) Florian 2013/6/19 Nikita Prokopov prok...@gmail.com

What the recommended way now to create an instance and override its methods?

2013-06-18 Thread Hussein B.
Hi, I know we usually use 'proxy' macro when we want to create an instance of a concrete class and override some of its methods. But do we have now a recommended approach? AFAIK, reify only works with protocols and interfaces, can't be used to create an instance and override its methods.

Re: First day with Macros

2013-06-18 Thread Hussein B.
at compile time in order to generate the code we want, so we have to escape it with ~@. The code that the `for` creates (in the form of a list) must then be (quasi-)quoted again by the backtick. Macros certainly take some getting used to. On Tue, Jun 18, 2013 at 8:12 AM, Hussein B. hubag

Re: What the recommended way now to create an instance and override its methods?

2013-06-18 Thread Hussein B.
Since reify allows us to override methods of an object, it is better to do: (def meh-object (MehClass.)) (reify meh-object ;; override methods) than: (proxy MehClass[] ;; override methods) Thanks. On Tuesday, June 18, 2013 1:16:40 PM UTC+2, Jim foo.bar wrote: On 18/06/13 08:45, Hussein

Re: What the recommended way now to create an instance and override its methods?

2013-06-18 Thread Hussein B.
Hmm, then why Clojure docs http://clojuredocs.org/clojure_core/clojure.core/reify mentions 'object': protocol-or-interface-or-Object (methodName [args+] body)* On Tuesday, June 18, 2013 1:41:57 PM UTC+2, Jim foo.bar wrote: On 18/06/13 12:34, Hussein B. wrote: Since reify allows us

Re: Clojure in production

2013-06-18 Thread Hussein B.
According to their Jobs page, Doo is using Clojure to implement their backend and web application: https://doo.net/en/ On Monday, June 10, 2013 11:47:25 PM UTC+2, Plinio Balduino wrote: Hi there I'm writing a talk about Clojure in the real world and I would like to know, if possible,

First day with Macros

2013-06-17 Thread Hussein B.
Hi, My target is to have something like this: (servlet ArticlesServlet (do-get [this request response] (println Get Request)) (do-post [this request response] (println Post Request))) I started with this: (defmacro servlet [servlet-name meths] `(reify Servlet (for [meth

Re: First day with Macros

2013-06-17 Thread Hussein B.
class to actually wire up your servlet, for example with a web.xml. Also, consider that you'll need some AOT compilation for the container to actually see the servlet class. On Mon, Jun 17, 2013 at 4:38 PM, Hussein B. hubag...@gmail.comjavascript: wrote: Hi, My target is to have

Re: How to write this in idiomatic Clojure code?

2012-11-16 Thread Hussein B.
Why the use of map? function ? I don't get it. On Friday, November 16, 2012 8:08:40 AM UTC+2, lpetit wrote: (map #(seq (process-some-class-instance %)) (tree-seq map? :children input)) Sent from a smartphone, please excuse the brevity/typos. Le 16 nov. 2012 à 00:13, Hussein B. hubag

How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
Hi, Would you please help me to morph this to an idiomatic Clojure ? (defn crazy [input] (if (instance? SomeClass input) (seq (process-some-class-instance input)) (map crazy (:children input Thanks for help and time. -- You received this message because you are

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
] (seq (process-some-class-instance input)) (defmethod crazy :default [{:keys [children]}] (map crazy children)) On Thu, Nov 15, 2012 at 5:33 PM, Hussein B. hubag...@gmail.comjavascript: wrote: Hi, Would you please help me to morph this to an idiomatic Clojure ? (defn crazy

Re: How to write this in idiomatic Clojure code?

2012-11-15 Thread Hussein B.
right in guessing that your input is some kind of tree where Someclass instances are leafs and non-leaf nodes are represented by maps having a :children key? Sent from a smartphone, please excuse the brevity/typos. Le 15 nov. 2012 à 23:33, Hussein B. hubag...@gmail.com javascript: a écrit

Re: Understanding clojure.core.cache TTL cache

2012-10-23 Thread Hussein B.
a lot! On Tuesday, October 23, 2012 1:42:28 AM UTC+3, Sean Corfield wrote: On Mon, Oct 22, 2012 at 3:30 PM, Hussein B. hubag...@gmail.comjavascript: wrote: So we need to call evict explicitly if we want to remove an entry? no automatic deletion after expiring? The cache is immutable

Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
Hi, I created this: (def c3 (cache/ttl-cache-factory {:a 1} :ttl 2)) user= c3 {:a 1} user= (cache/has? c3 :a) true user= (cache/has? c3 :a) false user= c3 {:a 1} user= (cache/evict c3 :a) {} user= c3 {:a 1} After TTL, cache doesn't has :a entry but printing the var shows the map contains

Re: Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
Wow, What an honor to get a reply from my idol and mentor !! Thanks a lot. I really appreciate to hear your opinion regarding this: http://stackoverflow.com/questions/13015906/is-it-safe-to-use-a-clojure-core-cache-guarded-by-ref-type Every thing started with this issue. Appreciate your precious

Re: Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
I see. But I didn't really grasp the whole concept firmly . c3 holds a map containing {:a 1} that will lives for two minutes. After two minutes, requesting :a is generating false since it reached its TTL but it will still live in map until it is removed explicitly by invoking evict. Correct?

Re: Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
, 2012 at 1:50 PM, Hussein B. hubag...@gmail.comjavascript: wrote: c3 holds a map containing {:a 1} that will lives for two minutes. In the code I provided, c3 is an atom that holds a cache (which is the map). After two minutes, requesting :a is generating false since it reached

Re: Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
I see, it works now. So we need to call evict explicitly if we want to remove an entry? no automatic deletion after expiring? On Tuesday, October 23, 2012 1:21:54 AM UTC+3, Sean Corfield wrote: On Mon, Oct 22, 2012 at 3:08 PM, Hussein B. hubag...@gmail.comjavascript: wrote: I tried

Re: Understanding clojure.core.cache TTL cache

2012-10-22 Thread Hussein B.
Thank you, I understand it :) And thank you Mr. Fogus. What a great pleasure! On Tuesday, October 23, 2012 1:42:28 AM UTC+3, Sean Corfield wrote: On Mon, Oct 22, 2012 at 3:30 PM, Hussein B. hubag...@gmail.comjavascript: wrote: So we need to call evict explicitly if we want to remove

Would you please help in migrating this code from Bishop to Liberator?

2012-09-19 Thread Hussein B.
Hi, I want to migrate this code written in Bishop REST framework to Liberator REST framework: (bishop/defresource ticket { text/html (fn [request] (let [request-method (:request-method request)] (case request-method :get (list-all-tickets request)

Immutability rules when it comes to Ref type

2012-08-10 Thread Hussein B.
Hi, I have a ref type that wraps a map, this map is going to embed many nested other maps. According to immutability rules, what happens when: A new nested map is updated (entry is removed or update) or even a new nested map is added to the master map that is wrapped by ref type? Thanks for

Re: Immutability rules when it comes to Ref type

2012-08-10 Thread Hussein B.
as a result of this. Andy On Aug 10, 2012, at 9:21 AM, Hussein B. wrote: Hi, I have a ref type that wraps a map, this map is going to embed many nested other maps. According to immutability rules, what happens when: A new nested map is updated (entry is removed or update

Better ideas how to collect analytics data

2012-08-10 Thread Hussein B.
Hi, I'm collecting analytics data. I used a master map that holds many other nested maps. Considering maps are immutable, many new maps are going to be allocated. (Yes, that is efficient in Clojure). Basic operation that I'm using is update-in , very convenient. Do you have a better idea how to

Why Clojure map literal creates an instance of array map?

2012-08-10 Thread Hussein B.
Hi, Why Clojure map literal creates an instance of array map but not hash map? What are the advantages of array map over hash map? 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

How to measure pieces of Clojure code?

2012-08-10 Thread Hussein B.
Hi, I want to measure how much space an algorithm is taking and then trying to change some aspects to see how things are going to differ. I also want to measure how much time it takes to complete an operation. What tools can I use? Thanks. -- You received this message because you are

Re: Why Clojure map literal creates an instance of array map?

2012-08-10 Thread Hussein B.
doesn't copy the entire map. Copying a small 5 element map isn't a big deal, but copying one with several thousand elements is. On Fri, Aug 10, 2012 at 5:43 PM, Hussein B. hubag...@gmail.comjavascript: wrote: Hi, Why Clojure map literal creates an instance of array map but not hash map? What