Re: difficulty with becoming a contributor

2010-03-10 Thread Tayssir John Gabbour
Hi, For Assembla, I first had to "watch" the Clojure space in order to post a ticket. (It's a confusing interface.) Though it explicitly told me I should, so perhaps that's not the problem you face. For posting on clojure-dev, I asked about it on IRC and Rich added me... I'm sure you can just ema

Re: Data manipulation question

2010-03-05 Thread Tayssir John Gabbour
-feet "4", :sound "woof", :animal "dog"} > ;  {:number-of-feet "4", :sound "meow", :animal "cat"} > ;  {:number-of-feet "2", :sound "chirp", :animal "bird"}) > ; ({:number-of-feet "4", :sound

Re: Data manipulation question

2010-03-05 Thread Tayssir John Gabbour
Hi Base, Perhaps something like the following: (defn normalize-creatures [creatures] (letfn [(split [str] (seq (.split str "\\s")))] (for [{:keys [animal sound number-of-feet]} creatures] (map (fn [a s n] {:animal a :sound s :number-of-feet n}) (split animal) (

Random thoughts on c.c.error-kit

2010-02-19 Thread Tayssir John Gabbour
Hi! I've been playing with error-kit, and like a ranting guy on the street I'd like to share random thoughts... * I'll probably come to rely on error-kit, or something like it. Suppose you're playing with nakkaya's distributed computing thingie ¹; you could hook simple listeners to do stuff when

Re: Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
Hi, On Feb 19, 6:16 pm, Michał Marczyk wrote: > You missed a quote (~name# -> ~'name#); this works fine: > > (defmacro my-macro [& body] > `(let [name# {#'*a* :new}] > (macrolet [(~(symbol 'with-my-macrolet) > [& body#] >`(with-bindings ~'name# >

Re: What is EvalReader?

2010-02-19 Thread Tayssir John Gabbour
On Feb 19, 1:12 pm, Chris Perkins wrote: > On Feb 19, 4:32 am, timc wrote: > > Is #= an undocumented reader macro character? > > Interesting - I had never heard of it either. It appears to allow you > to execute code at read-time. > > user=> (read-string "(foo (+ 2 3) bar)") > (foo (+ 2 3) bar)

Re: Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
g-utils.clj#L92 All the best, Tayssir On Feb 19, 2:56 pm, Tayssir John Gabbour wrote: > Hi, > > I'm having problems with nested syntax-quotes, or something. > > This works fine: > (use 'clojure.contrib.macro-utils) > (def *a* nil) > > ;; good > (de

Nested syntax-quotes...

2010-02-19 Thread Tayssir John Gabbour
Hi, I'm having problems with nested syntax-quotes, or something. This works fine: (use 'clojure.contrib.macro-utils) (def *a* nil) ;; good (defmacro my-macro [& body] `(let [name# {#'*a* :new}] (macrolet [(~(symbol 'with-my-macrolet) [& body#] (concat (list

How to turn quick Slime workaround into a real patch?

2010-02-13 Thread Tayssir John Gabbour
Hi! Yesterday I installed Slime & Clojure via ELPA. Unfortunately, the REPL had no indent support for [] and {}. So this workaround runs in a slime-repl-mode-hook: (defun set-clojure-brackets () (interactive) (set-syntax-table clojure-mode-syntax-table) (set (make-local-variable 'lisp-inden

Re: Clojure and OOP

2010-02-11 Thread Tayssir John Gabbour
Hi, On Feb 11, 1:46 pm, HB wrote: > Since Clojure is a LISP dialect, does this mean that it doesn't > support OOP? Careful not to come to the conclusion that if something's a Lisp, it's not OOP. For instance, Common Lisp has a powerful OOP system which includes multiple-inheritance, metaobject p

Re: Pattern Matching

2010-02-04 Thread Tayssir John Gabbour
On Feb 4, 3:28 pm, Tayssir John Gabbour wrote: > I can't say I haven't used pattern matching as much as I probably > should, Excuse me, I mean that I haven't used it much though I keep hearing about it... -- You received this message because you are subscribed to the G

Re: Pattern Matching

2010-02-04 Thread Tayssir John Gabbour
Hi, On Feb 4, 3:08 pm, Sean Devlin wrote: > Do we have a concise way of doing this? Is it actually useful? > http://www.artima.com/weblogs/viewpost.jsp?thread=281160 Yep, see clojure.contrib.types/match. I recently used it in an almost frivolous way in this thread, because I thought it was pre

Re: set/select vs. other set functions: argument order and ->

2010-02-04 Thread Tayssir John Gabbour
On Feb 4, 3:31 am, wlr wrote: > (-> #{{:a 1, :b 1, :c 1} >{:a 2, :b 2, :c 2} >{:a 3, :b 3, :c 3}} >(->> (select #(= (:a %) 1))) >(project [:b :c])) > > => #{{:c 1, :b 1}} Ahhh.. what a tricky language. ;) This saves me from writing reverse- args or select*,

Re: set/select vs. other set functions: argument order and ->

2010-02-03 Thread Tayssir John Gabbour
On Feb 3, 10:41 pm, wlr wrote: > Can you somehow use ->> ? > > user> (->> #{1 2 3 4} (clojure.set/select even?)) > #{2 4} D'oh, I was terribly unclear. I want to do something neat and pretty like: ;; Doesn't work! (-> #{{:a 1, :b 1, :c 1} {:a 2, :b 2, :c 2} {:a 3, :b 3, :c 3}} (s

set/select vs. other set functions: argument order and ->

2010-02-03 Thread Tayssir John Gabbour
Hi! set/select is hard to thread with the other clojure.set functions using ->, because its argument order is different. I currently use a reverse-args function like the following: (defn revargs [f] (fn [& args] (apply f (reverse args ((revargs select) xset pred) Is there a better w

Re: maybe-m monad violates monad law?

2010-01-28 Thread Tayssir John Gabbour
Ah... thanks everyone, now I no longer have that creepy feeling that reality went weird. I now see why m-result looks so "pointless" -- it's maybe like when I'm writing code which uses mapcat a lot and the base case is a disturbing-looking [nil] rather than just plain nil. It's not really pointles

maybe-m monad violates monad law?

2010-01-27 Thread Tayssir John Gabbour
Hi, I have a problem with monads. Here's the first law which monads must fulfill (taken from 2 different tutorials): (= (m-bind (m-result value) function) (function value)) -- http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/ (m-bind (m-result x) f) is

Re: Clojure newbie question regarding compile time type checking.

2009-12-15 Thread Tayssir John Gabbour
On Dec 15, 1:23 pm, Baishampayan Ghose wrote: > PS - If you are worried about "compile time type checking", I think it's > prudent to mention now that Clojure is a dynamically typed programming > language where types are checked at run-time and not compile time. Actually, there are Common Lisp co

Re: Handling XML

2009-12-02 Thread Tayssir John Gabbour
're a bit overwhelmed by all the stuff that xml-> accepts, just note that much of it is syntactic sugar, for your convenience. Tayssir On Dec 2, 7:41 pm, Tayssir John Gabbour wrote: > Hi! > > Taking minor liberties with your code (for clarity), the following > gives pr

Re: Handling XML

2009-12-02 Thread Tayssir John Gabbour
Hi! Taking minor liberties with your code (for clarity), the following gives pretty much the same result as your handle-xml function: (ns blah (:require [clojure.xml :as xml] [clojure.zip :as zip]) (:use clojure.contrib.zip-filter.xml)) (defn my-test [] (doseq [x (xml-> (zip/x

Re: Clojure as a first programming language?

2009-12-01 Thread Tayssir John Gabbour
ze how they print to screen. So for instance, an eBay order might print like this: # emphasizing only order# and payment status, rather than its in-memory representation as a big XML structure. And when I do want to examine big representations, I use a "pretty printer" to format them readably.

Re: Clojure as a first programming language?

2009-12-01 Thread Tayssir John Gabbour
Interestingly, there's this book which is a crash course on building a computer stack from the ground up: from logic gates, to a compiler, to an OS. And the simulator, in which you build all these things, is in Java. Nisan/Schocken's _The Elements of Computing Systems_:

Re: Clojure as a first programming language?

2009-12-01 Thread Tayssir John Gabbour
Interestingly, there's this book which is a crash course on building a computer stack from the ground up: from logic gates, to a compiler, to an OS. And the simulator, in which you build all these things, is in Java. Nisan/Schocken's _The Elements of Computing Systems_: Luke Gorrie mentioned por

Re: Clojure as a first programming language?

2009-12-01 Thread Tayssir John Gabbour
Interestingly, there's this book which is a crash course on building a computer stack from the ground up: from logic gates, to a compiler, to an OS. And the simulator, in which you build all these things, is in Java. Nisan/Schocken's _The Elements of Computing Systems_: Luke Gorrie mentioned por

Re: Clojure as a first programming language?

2009-12-01 Thread Tayssir John Gabbour
Hi, As an occasional Clojure user, and someone who's used Common Lisp a lot, I'd venture that Clojure is a good first choice. But let me metion areas of difficulty first. Geoffrey Teale discussed the big things, so let me mention some little ones: - Java's classpath currently demands that you res

Re: Clojure is two!

2009-10-22 Thread Tayssir John Gabbour
On Oct 22, 5:05 pm, Tayssir John Gabbour wrote: > What's been very helpful is clojure.zip and clojure.set; I needed to > correlate data which came from a DB and an XML file -- and it was > immediately obvious that clojure.set/join and clojure.set/rename could > do it in 4 spars

Re: Clojure is two!

2009-10-22 Thread Tayssir John Gabbour
Hi, Just chiming in a bit late -- just wanted to say that Clojure has really been saving my butt these last three long days. My customer has a codebase which is written in a language without any sort of fancy REPL. I'm able to tap into that system and have Clojure draw out the info, so I can mani

Re: Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Tayssir John Gabbour
at has done it, but then again > i'm not really on top of things. > > http://common-lisp.net/project/iterate/ > > On Sep 7, 6:59 am, Tayssir John Gabbour > wrote: > > > Hi! > > > Is anyone else working on a Common Lisp style "loop"? I'd hate to

Anyone else working on a Common Lisp style "loop"?

2009-09-07 Thread Tayssir John Gabbour
Hi! Is anyone else working on a Common Lisp style "loop"? I'd hate to duplicate effort. I wrote one yesterday, though I still have to read that stuff on how to decently package a lib. ;) http://github.com/tayssir/cl-loop/tree/master (I might not have written this, but I couldn't figure out a p

Re: Infinite Sequence of Coin Flips

2009-08-18 Thread Tayssir John Gabbour
On Aug 19, 1:08 am, tmountain wrote: > Hi, I was wondering if there's a more idiomatic way to do the > following: > > (defn flip-coin [] > (int (rand 2))) To add to CuppoJava's advice, (rand-int 2) is a synonym of (int (rand 2)). All the best, Tayssir --~--~-~--~~~--

Re: Can Clojure be as fast as Java?

2009-08-12 Thread Tayssir John Gabbour
s, because + disappears after compiletime. If correct, that makes sense. Thanks for the enlightenment, Tayssir On Aug 12, 12:01 pm, Meikel Brandmeyer wrote: > Hi, > > On Aug 12, 11:54 am, Tayssir John Gabbour > > wrote: > > On this topic, how do primitives work? I heard something

Re: Can Clojure be as fast as Java?

2009-08-12 Thread Tayssir John Gabbour
On this topic, how do primitives work? I heard something about "function boundaries." Which I interpret to mean that when a function returns a primitive, Clojure boxes it in some Java object. And type declarations can't stop this boxing from happening. Is this a correct understanding? (I doubt it

Re: Compile Time Partial Evaluation

2009-07-12 Thread Tayssir John Gabbour
Hi Tim, On Jul 11, 4:39 am, Tim Snyder wrote: > I've been experimenting with the idea of performing compile-time > partial evaluation of calls where possible, using a macro. I must > preface this discussion that I realize it is a bit of an abuse of > macros. This isn't an abuse at all. If I un

Add-classpath

2009-07-10 Thread Tayssir John Gabbour
Hi! Does anyone know when add-classpath might start working again? http://groups.google.com/group/clojure/browse_frm/thread/ad254be133a9b47a/ab6585a430e21346? (It didn't even work for me when I downloaded the v1.0 release. I'm on MacOS 10.4, running under Emacs/Slime. I have recent Clojure insta

Re: how does clojure's reader determine encoding when reading source from file?

2009-07-02 Thread Tayssir John Gabbour
Hi Ben, This is sitting in my .emacs file: (set-language-environment "UTF-8") (setq slime-net-coding-system 'utf-8-unix) (I don't know whether it'll work for you, just as I don't know whether all the things sitting in my fridge are edible... Good luck. ;) Tayssir On Jul 2, 9:00 pm, B Sm

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
m, Tayssir John Gabbour <[EMAIL PROTECTED]> wrote: > Hi! > > How should I approach serialization? I made a little test function > which serializes and deserializes Clojure objects. It works for > strings, integers, symbols, LazilyPersistentVectors and.. oddly.. > Persis

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
of developpers disconnected from real life. > In real life your systems are running and you may not be able to > interrupt services for a long period to upgrade them > all at once. You may have to do so in multiple steps and without > interrupting the service. > > e) I wa

Re: Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
On Dec 2, 9:57 am, Tayssir John Gabbour <[EMAIL PROTECTED]> wrote: > (defn my-identity "Copies obj through serialization and > deserialization." > [obj] > (let [byte-out (new java.io.ByteArrayOutputStream) > obj-out (new java.io.ObjectOutputStream byte

Serializing Clojure objects

2008-12-02 Thread Tayssir John Gabbour
Hi! How should I approach serialization? I made a little test function which serializes and deserializes Clojure objects. It works for strings, integers, symbols, LazilyPersistentVectors and.. oddly.. PersistentHashMaps that have exactly one element. (My Clojure is about a month old.) But for ot

Re: Special forms and namespaces

2008-10-27 Thread Tayssir John Gabbour
Stephen C. Gilardi wrote: > Yes, that's one of the things that's special about them. They are > resolved as special forms independent of the current namespace. > > I'm not sure if it's essential or a design choice that they have no > namespace of their own. Pretty cool; this means that special op

Special forms and namespaces

2008-10-27 Thread Tayssir John Gabbour
Hi, I've noticed that symbols naming special forms don't belong to a namespace. For example: user> (map #'namespace [`def `do `if `quote `assoc]) (nil nil nil nil "clojure") Is this expected? Thanks! Tayssir --~--~-~--~~~---~--~~ You received this message beca

Trying to run Clojure with Slime...

2008-10-10 Thread Tayssir John Gabbour
Hi! When I attempt to run Slime, this error pops up in *inferior-lisp*: user=> java.lang.UnsupportedOperationException: Vars are not values (basic.clj:12) user=> java.lang.Exception: No such var: swank/ignore-protocol-version (NO_SOURCE_FILE:5) user=> java.lang.Exception: No such var: swank/star