Re: (= '(java.lang.String) (list java.lang.String)) = false ?

2013-11-10 Thread Timo Mihaljov
On 10.11.2013 14:03, Dave Tenny wrote: I don't understand why these things aren't equal. user= (= (list java.lang.String) (list (class abc))) true user= (= '(java.lang.String) (list (class abc))) false user= (type '(java.lang.String)) clojure.lang.PersistentList

Re: Counterclockwise

2013-09-07 Thread Timo Mihaljov
On 07.09.2013 11:24, Josh Kamau wrote: Please allow me to hijack the thread and ask: Does Counterclockwise allow slurping and barfing? like in emacs ? Yes. See http://code.google.com/p/counterclockwise/wiki/EditorKeyBindingsFeatures -- Timo -- -- You received this message because you

Re: Counterclockwise

2013-09-07 Thread Timo Mihaljov
On 07.09.2013 14:02, Josh Kamau wrote: I am unable to use slurp . I am using latest stable version. does *Ctrl+) S* mean pressing Ctrl+Shift+)+S together ? Shift so that i pick ) and not 9 and so that S is in caps. ) is above 0 on my keyboard, so I can trigger the Slurp Right action like

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

2013-08-19 Thread Timo Mihaljov
On 18.08.2013 16:51, Hussein B. wrote: 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,

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

2013-08-19 Thread Timo Mihaljov
On 19.08.2013 20:27, Timo Mihaljov wrote: This example may be to artificial to be translated into Clojure. What use is it to store strings in a tree keyed by the string's characters? If you know the path to the string, you already know the string itself, and you don't need the tree at all

Re: vec to map with consolidated vals

2013-08-18 Thread Timo Mihaljov
On 17.08.2013 08:40, David Chelimsky wrote: Which led me to this: (defn to-consolidated-map [parts] (apply merge-with + (map (partial apply hash-map) parts))) This is exactly what I came up with after reading your first message. Apparently Jay Fields took the same approach. I think it's

Re: filter with a sequence of maps not working

2013-08-07 Thread Timo Mihaljov
On 07.08.2013 10:58, Tilak Thapa wrote: (defn get-data [ attrs] (let [grps data] (if (empty? attrs) grps (map #(select-keys % attrs) grps (filter #(= (% :id) 7) (get-data :id :b)) Why above expression works but same expression wrapped as function (below) does

Re: distinction of defrecord instances in sorted-set-by does not work

2013-07-25 Thread Timo Mihaljov
On 25.07.2013 11:19, gixxi wrote: Consider the following record definition, a respective record instance as well as a sorted tree set with a custom comparator sorting first the :visited property and the by the :dist property of the record. (defrecord RDistance [node dist visited]) (def

Re: map from list of maps

2013-07-25 Thread Timo Mihaljov
On 26.07.2013 00:34, Brian Craft wrote: Is there a better way to do this, making a map of certain keys from a list of maps? (apply hash-map (mapcat (fn [x] [(x :a) (x :b)]) [{:a blah :b ack} {:a red :b blue}])) {red blue, blah ack} Here's another way: (let [xs [{:a blah, :b ack} {:a

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Timo Mihaljov
On 10.05.2013 14:04, Colin Yates wrote: 2) to provide a 'get-ds' accessor which returns a new instance and rely on passing that service along to every function that needs it? For what it's worth, some people in the OO community, most notably Nat Pryce and Steve Freeman of Growing

Re: Struggling with encapsulation

2013-05-10 Thread Timo Mihaljov
On 10.05.2013 14:44, John D. Hume wrote: Assume a queue is your only state and `add` and `clear` are your private fns that take a queue as first argument. (defn new-scheduler [] (let [queue (...)] {:add (partial add queue) :clear (partial clear queue)})) There are several

Re: idiomatic way to force evaluation of a lazy operation

2013-05-04 Thread Timo Mihaljov
On 04.05.2013 12:16, Korny Sietsma wrote: What's the idiomatic way to avoid this? The options seem to be either to use (doall (map parse-record records)) or (mapv parse-record records) Is either of these better? The latter is simpler, the former (to me) expresses that you are

Re: idiomatic way to force evaluation of a lazy operation

2013-05-04 Thread Timo Mihaljov
On 04.05.2013 13:01, Korny Sietsma wrote: Thanks - I thought doall was probably better than mapv. Incidentally, doseq won't work - if the 5th result throws an exception during parsing, results 1-4 will still be saved, whereas I want the whole operation to abort without saving anything. Ah

Re: is intellij idea a good ide for clojure development?

2013-01-29 Thread Timo Mihaljov
On 29.01.2013 16:32, Jay Fields wrote: On Tue, Jan 29, 2013 at 9:28 AM, Feng Shen shen...@gmail.com wrote: I have programming Clojure for almost 2 years, for a living. This is probably an important part of what answer the OP is looking for. When I was doing Clojure for about 10% of my job

Re: Need ideas for carving project into namespaces

2012-12-14 Thread Timo Mihaljov
On Thursday, December 13, 2012 11:43:48 PM UTC+2, puzzler wrote: On Thu, Dec 13, 2012 at 1:31 PM, Timo Mihaljov ti...@mihaljov.infojavascript: wrote: (ns example.patron The patron doesn't have an artistic vision (that's the artist's job), nor does it know how to talk to a graphics

Re: Need ideas for carving project into namespaces

2012-12-13 Thread Timo Mihaljov
On 12.12.2012 02:16, Mark Engelberg wrote: Hi Mark, Here's my take on the problem. I hope you can adapt it to your situation. (ns example.canvas A canvas is an abstract interface to a graphics API. The canvas namespace does not build new functionality on top of the APIs, that's a job for

Re: newbie question regarding maps

2012-09-26 Thread Timo Mihaljov
On 24.09.2012 13:04, Mond Ray wrote: user= wish-lists [{:name WL1, :items [{:name Item 1, :cost 20.0} {:name Item 2, :cost 40.0}]} {:name WL2, :items [{:name Wiggle 1, :cost 20.0} {:name Wiggle 2, :cost 40.0} [:name Item 3 :cost 10.0]]}] user= (assoc-in wish-lists [:name WL1] [:name WL1

Re: Behavior of (eval) in different namespaces

2012-09-25 Thread Timo Mihaljov
On 25.09.2012 23:58, Alex Dowad wrote: Does anyone know what's going on here? user= (let [a 1] (eval 'a)) 1 user= (ns another-ns) nil another-ns= (let [a 1] (eval 'a)) CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:41)

Re: Lightweight lib/way to strip html from text

2012-09-10 Thread Timo Mihaljov
On 06.09.2012 20:41, jamieorc wrote: Hey all, I'm looking for a lightweight way to strip html from a long String of text and leave just the text. I've come across JSoup, but at over 300kb for the lib, not quite lightweight. Suggestions? I've found Jericho HTML Parser to be fast, robust,

Re: understanding data structures, and other low-level stuff

2012-03-20 Thread Timo Mihaljov
On 03/15/2012 09:15 PM, Nic Long wrote: So I guess I'm asking whether anyone can recommend some good primers on data structures, both as they relate to Clojure, but also how they work in the fundamentals - e.g. what exactly is the classic model of an 'array' and how does it work, etc. I have

Re: (OTP slightly) - ensuring assumptions about structure of function arguments in dynamic languages

2012-01-30 Thread Timo Mihaljov
As I understand the problem in your example, you do have a definition for what an Insurable is, but it's implicit: there's no way to check whether an object is insurable and thus no way to check which parts of the code break when the notion of being Insurable changes. Luckily Clojure provides us

Re: Leiningen and Cake

2011-12-14 Thread Timo Mihaljov
On 12/14/2011 06:37 PM, Timothy Washington wrote: 1) The first is being able to pass many tasks to lein. So I would prefer A. instead of B. * A) lein clean deps * B) lein clean lein deps You can chain commands by separating them with a comma: lein clean, deps -- Timo -- You

Re: Recreate a hierarchy

2011-05-05 Thread Timo Mihaljov
On Thu, May 05, 2011 at 05:40:02AM -0700, Steffen wrote: Hello, I'm trying to come up with a way to recreate a directory hierarchy. Entries within zip archives are just flat strings like top/level/file1, but I would like to operate on them hierarchically. So my problem could be stated as:

Re: better error messages smaller stack traces

2011-02-17 Thread Timo Mihaljov
On Tue, Feb 08, 2011 at 09:01:38AM -0500, Stuart Halloway wrote: Please let us know when you get a misleading error message from a macroexpansion, so we can make it better. Or contribute a patch along the lines of [2]. Here's another error message that really threw me off for a while. I

Re: better error messages smaller stack traces

2011-02-14 Thread Timo Mihaljov
On Tue, Feb 08, 2011 at 09:01:38AM -0500, Stuart Halloway wrote: Please let us know when you get a misleading error message from a macroexpansion, so we can make it better. Or contribute a patch along the lines of [2]. Here's a misleading lack of an error message: (defn foo [x]

Re: Images in autodoc?

2010-10-26 Thread Timo Mihaljov
On Tue, Oct 26, 2010 at 02:15:21PM -0400, Andrew Gwozdziewycz wrote: Areas likely to include gobbledegook: [...] 2. links (internal. for external links, just use fully qualified URI) Internal links could be easily handled by trying to resolve all `code blocks` with ns-resolve in the namespace

Re: Game development in Clojure

2010-08-20 Thread Timo Mihaljov
On Mon, Aug 16, 2010 at 03:43:11AM -0700, Mike Anderson wrote: 2. User interface comes last, which is good in general but makes it a royal pain to pass notifications back to the UI. In Java I would simply have e.g. units.clj call a simple notification function in interface.clj, in Clojure I

Self-referencing map literals

2009-08-31 Thread Timo Mihaljov
When defining a map literal, is it possible to reference the map that is being defined? I have some code that looks like this: (let [radius 20 diameter (* 2 radius) circumference (* pi diameter)] {:radius radius :diameter diameter :circumference

Re: Self-referencing map literals

2009-08-31 Thread Timo Mihaljov
On Mon, Aug 31, 2009 at 09:14:38AM -0400, Chas Emerick wrote: You could define your own let-like construct for this: (defmacro letmap [[m kvs mkvs] body] (if m `(let [~m {} ~@(mapcat (fn [[k v]] `(~m (assoc ~m ~k ~v))) kvs)] (letmap ~mkvs ~...@body))

clojure.contrib.test-is/run-tests throws NullPointerException w/ invalid args

2009-05-05 Thread Timo Mihaljov
When clojure.contrib.test-is/run-tests is given an invalid argument, it throws a NullPointerException: user= (use 'clojure.contrib.test-is) nil user= (run-tests 'asdf) java.lang.RuntimeException: java.lang.NullPointerException (NO_SOURCE_FILE:0) The issue seems harmless in a simple case like

Re: Modifying data structures without changing their interface

2009-04-20 Thread Timo Mihaljov
Timo Mihaljov wrote: I'm wondering about how to change a data structure without breaking the API used to access it. For example, let's assume that I have a library for dealing with records of people and I'm storing them in structs. (defstruct person :name) The users of my library

Re: Modifying data structures without changing their interface

2009-04-20 Thread Timo Mihaljov
Laurent PETIT wrote: While interesting, this approach seems to me limited to simple cases : * limited in possibilities: you are not able to directly use values of other fields. So in more complex cases, you won't be able to combine calculated values without code repetition or prepraration

Re: Modifying data structures without changing their interface

2009-04-20 Thread Timo Mihaljov
Laurent PETIT wrote: What do others think about these 2 above statements ? The standard OO approach to information hiding would be private fields and accessor methods. Any suggestions for the One True Clojure Pattern that addresses the same problem? I think accessor

Modifying data structures without changing their interface

2009-04-19 Thread Timo Mihaljov
Hi, I'm wondering about how to change a data structure without breaking the API used to access it. For example, let's assume that I have a library for dealing with records of people and I'm storing them in structs. (defstruct person :name) The users of my library access the data stored

System.loadLibrary() does not work

2009-03-29 Thread Timo Mihaljov
I'm trying to use Clojure to call a library via JNI. Here's a working piece of Java code that I'm trying to convert to Clojure: import libfoo.Foo; // A GlueGen-generated wrapper class Test { static { System.loadLibrary(foo); // The original library