Re: (take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-03 Thread Stefan Rohlfing
@ Ken, Andreas Thank you for your nice implementations! As far as I can see, there are two main methods of comparing adjacent items of a list: 1) Take the first item of a coll. Compare the remaining items with an offset of 1: (map f coll (rest coll)) ;; apply some sort of filter 2) Take the

(take-by f coll), (drop-by f coll): Problem Comparing Adjacent Items Of A Collection

2011-04-02 Thread Stefan Rohlfing
Dear Clojure Group, In the style of *take-while* and *drop-while* I wrote two functions* take-by * and *drop-by* that take an arbitrary function f instead of a predicate and return a lazy sequence based on comparing the result of (f item) of successive items in the collection. However,

Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group, I am currently reading the online book Pro Githttps://docs.google.com/document/d/1pms_fnr0m2xlYH_4CB3pMeWBdIBlly4CQGMWuogOntg/edit?hl=en. In chapter 7.4 http://progit.org/book/ch7-4.html (section “Enforcing a User-Based ACL System”) there is a task of reading in an access

Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Dear Clojure Group, I am currently reading the online book Pro Git http://progit.org/book/. In chapter 7.4 http://progit.org/book/ch7-4.html (section “Enforcing a User-Based ACL System”) there is a task of reading in an access control list (ACL) file, such as the following # avail/unavail |

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thank you all so much for helping me improve my code! I personally find Stuart's suggestion to be the most readable. The use of the - macro makes the workflow quite easy to follow. I hope that with some more experience I will be able to see these patterns myself and adapt my code accordingly.

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
You are perfectly right. Organizing the code so that - or - an be applied is key here. Unfortunately, only if all functions to be composed follow the same pattern of either 'insert first' or 'insert last' can these macros be used. -- You received this message because you are subscribed to the

Re: Tranforming an ACL file: Comparing Clojure with Ruby

2011-03-03 Thread Stefan Rohlfing
Thanks for your suggestion. Using the 'for' macro here makes the main part of the parse function much clearer. -- 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

Problem Installing VimClojure + lein-vimclojure

2011-01-27 Thread Stefan Rohlfing
Hi all, I have been trying to install the Vim pluing VimClojure togheter with the lein plugin lein-vimclojure but always get an error message telling me ng (the Nailgun client) cannot be found. This is how my installation went so far: 1) Downloaded https://github.com/vim-scripts/VimClojure

Re: Problem Installing VimClojure + lein-vimclojure

2011-01-27 Thread Stefan Rohlfing
As it seems the Nailgun client has to be installed manually. This is what I did so far: 1) Downloadedhttp://kotka.de/projects/vimclojure/vimclojure-nailgun-client-2.2.0.zip the Nailgun Client and extracted it. 2) Added the following commands to my ~/.vimrc file: let vimclojure#WantNailgun =

Re: Problem Installing VimClojure + lein-vimclojure

2011-01-27 Thread Stefan Rohlfing
Hi Miki, Thanks for your help. Now the Nailgun client is running. Best regards, Stefan -- 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 -

Re: Problem Installing VimClojure + lein-vimclojure

2011-01-27 Thread Stefan Rohlfing
Hi Meikel, Thanks for pointing me to the installation instructions. I somehow must have missed that part. I have already joined the VimClojure Group and will probably have some more questions while learning how to use this plugin. Best regards, Stefan -- You received this message because

Re: Regarding The Implementation of 'merge-with'

2011-01-20 Thread Stefan Rohlfing
Hi John, Thank you very much for your correction of my code! *my-merge-with* is working perfectly now. There is just one thing: I always want to understand my errors so that I can learn from them. However, I still don't understand why my implementation did not work. Looking at my code I am

Re: Regarding The Implementation of 'merge-with'

2011-01-20 Thread Stefan Rohlfing
Hi John, Thanks for your detailed explanation of the inner workings of my code! I have been confused by the behavior of Clojure's mutable data structures quite often, but after reading your explanation it finally starts to make sense. I also tried to explain why your code works: Everything

Re: Regarding The Implementation of 'merge-with'

2011-01-19 Thread Stefan Rohlfing
how to test this code. I hope someone can me point to my error. Best regards, Stefan On Nov 26 2010, 8:42 pm, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Dear Clojure Group, Today I took a closer look at the 'merge-with' function of Clojure Core and changed some parts to better

Re: I don't understand this exception

2011-01-17 Thread Stefan Rohlfing
17, 3:21 pm, Ken Wesson kwess...@gmail.com wrote: On Mon, Jan 17, 2011 at 1:47 AM, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Hi all, I am trying to implement the function 'group-by' from Clojure.Core using my current knowledge of Clojure but cannot get pass

I don't understand this exception

2011-01-16 Thread Stefan Rohlfing
Hi all, I am trying to implement the function 'group-by' from Clojure.Core using my current knowledge of Clojure but cannot get pass a java.lang.Exception. This is the code so far: (defn key? [key coll] (some #{key} (keys coll))) (defn my-group-by [f coll] (let [test (fn [m x]

Regarding The Implementation of 'merge-with'

2010-11-26 Thread Stefan Rohlfing
Dear Clojure Group, Today I took a closer look at the 'merge-with' function of Clojure Core and changed some parts to better understand its implementation. Now I still have two questions regarding the following code: (defn my-merge-with [f maps] (when (some identity maps)

Re: Regarding The Implementation of 'merge-with'

2010-11-26 Thread Stefan Rohlfing
Hi Chris, Thanks a lot for your clear explanations! Now all the pieces suddenly make sense to me. Stefan On Nov 26, 9:30 pm, Chris Perkins chrisperkin...@gmail.com wrote: On Nov 26, 7:42 am, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Dear Clojure Group, Today I took

Problem adjusting the implementation of 'partition'

2010-11-22 Thread Stefan Rohlfing
Dear Clojure Group, I am trying to adjust the implementation of the 'partition' function so that the last element of a provided padding such as [a b] will be repeated if necessary to ensure the length of the last list returned by 'padding' is the same as the other lists. This is the original

Re: Problem adjusting the implementation of 'partition'

2010-11-22 Thread Stefan Rohlfing
Hi Meikel, What I want to accomplish is to have the function 'fill the gap' if not enough padding is supplied. With the standard 'partition' function this does not work, as it only adds as much padding as provided: (partition 3 3 [a] [1 2 3 4 5 6 7 8 9 10]) ;; ((1 2 3) (4 5 6) (7 8 9) (10 a))

Re: Problem adjusting the implementation of 'partition'

2010-11-22 Thread Stefan Rohlfing
Hi Benny, Your solution is much more elegant and flexible as my hacking of the core function! How would you implement 'pad-padding' (I like this name) if every item of the padding should be repeated in order, not only the last one? (defn pad-padding [padding] (concat padding (repeat

Re: Problem adjusting the implementation of 'partition'

2010-11-22 Thread Stefan Rohlfing
Hi Benny, This implementation looks great! If I could only find out what went wrong with my (not so elegant) solution... Stefan On Nov 23, 3:30 pm, Benny Tsai benny.t...@gmail.com wrote: Or, to put it all together into a modified partition: (defn my-partition   ([n coll]      (partition n

Re: Problem adjusting the implementation of 'partition'

2010-11-22 Thread Stefan Rohlfing
Fantastic! Thanks again! On Nov 23, 3:50 pm, Benny Tsai benny.t...@gmail.com wrote: Indeed there is :) http://clojuredocs.org/clojure_core/clojure.core/cycle On Nov 23, 12:37 am, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Hi Benny, Your solution is much more elegant

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-24 Thread Stefan Rohlfing
, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 24 Okt., 04:00, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
Thanks for the great explanation. This really makes using the clj- record library much more comfortable! Stefan PS. Sorry for replying late. I could not get my VPN to work which meant Google Groups was blocked for me. On Oct 21, 7:47 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, you can't

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
Hi Mikel, I tried your solution but am still not able to import the aliases from another namespace: This is what I did: - src/active-record/tns.clj (ns active-record.tns) (require '[active-record.user :as user]) (require

Re: Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-23 Thread Stefan Rohlfing
I started Emacs again and now your solution is working! I have no idea why it did not work on the first restart but I am happy that I now can import aliases from another namespace. Thanks again for your help! Stefan On Oct 24, 10:00 am, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Hi Mikel

Trying to Load An Alias from Another Namespace into The Current Namespace

2010-10-21 Thread Stefan Rohlfing
Dear Clojure group, The library clj-record requires to add a source file for every table in a given database. This can lead to a lot of files whose namespaces have to be imported wherever you want to work on the tables. In order to avoid having to write the whole namespace declaration every

clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
Dear Clojure group, I am currently reading chapter 9.1 MySQL clj-record of 'Clojure in Action'. clj-record seems pretty awesome, but I once again got lost in namespace jungle. Here is a concrete example: File 1:

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
: http://github.com/duelinmarkers/clj-record/blob/master/src/clj_record/core.clj (at the bottom) On Oct 20, 4:20 pm, Michael Wood esiot...@gmail.com wrote: On 20 October 2010 10:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Dear Clojure group, I am currently reading chapter

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
, On 20 Okt., 10:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: ;; EOF while reading ;;  [Thrown class java.lang.Exception] Are you sure, that you don't have some syntax error somewhere? Sincerely Meikel -- You received this message because you are subscribed to the Google Groups

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
Yes, I also tried charge/create. The error message is different, but it still does not work: ;; No such namespace: charge ;; [Thrown class java.lang.Exception] On Oct 20, 5:03 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 20 Okt., 10:46, Stefan Rohlfing stefan.rohlf...@gmail.com wrote

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
: Hi, On 20 Okt., 11:09, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: Yes, I also tried charge/create. The error message is different, but it still does not work: More evidence for a problem with the user alias. Try a different one like (:require [active-record.user :as u]). Sincerely

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
, ;; :user_id 8} Thank you so much for your help! I really learned at lot about dealing with namespaces today. Stefan On Oct 20, 5:45 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 20 Okt., 11:35, Stefan Rohlfing stefan.rohlf

Re: clj-record Library: Handling Namespaces

2010-10-20 Thread Stefan Rohlfing
from the different error messages. Thanks again for your great help! Stefan On Oct 20, 8:34 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On 20 Okt., 14:04, Stefan Rohlfing stefan.rohlf...@gmail.com wrote: I really learned at lot about dealing with namespaces today. I hope you also

Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Dear Clojure Group, Following an Enlive tutorial I wanted to implement a function 'd-map' that takes an arbitrary number of [:key (list of values)] parameters like this: (d-map [:headline [this is me] ] [:points [1 2 3] ] [:comments [10 20 30] ]) and returns a

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Thank you all for your great code examples! The goal of the function 'd-map' is to return a collection of maps that looks like this: ({:headline this, :points 1, :comments 10} {:headline is, :points 2, :comments 20} {:headline me, :points 3, :comments 30}) Based on Per's example using

Re: Is This Function Idiomatic Clojure?

2010-10-07 Thread Stefan Rohlfing
Thanks again for these beautiful code examples! I haven't come across (apply map ... before so this is idiom a big step forward for me. The same is true for the extended use of 'reduce'. I know that this function is really powerful but I am only just beginning to understand its potential.

Re: Macro Implementation: I Don't Understand This Error Message

2010-10-02 Thread Stefan Rohlfing
@Jürgen and Chris Thank you very much for helping me enlarge my understanding of macros! I realize that learning the subtleties of a macro implementation is not easy but well worth the effort. It is also quite interesting that a macro as it seems takes two implicit extra arguments. I am curious

Macro Implementation: I Don't Understand This Error Message

2010-10-01 Thread Stefan Rohlfing
Dear Clojure Group, I wanted to expand the 'infix' macro presented in chapter 7.3.1 of 'Clojure in Action' to handle nested s-expressions: My first version did not work: (defmacro my-infix [expr] (if (coll? expr) (let [ [left op right] expr] (list op (my-infix left) (my-infix

Re: Some Problem with Recursion

2010-09-10 Thread Stefan Rohlfing
@ Nicolas and ajuc Thank you very much for showing me where I went wrong! With so many parentheses it sometimes happens that I misplace one Now the output of the function is as expected: (defn prefix-postfix [expr] (if (coll? expr) (let [ [op arg1 arg2] expr] [ (prefix-postfix arg1)

Re: Some Problem with Recursion

2010-09-10 Thread Stefan Rohlfing
Hi Laurent, Thanks for your detailed explanation! It greatly helped me understand the usage of quoting. Stefan On Sep 10, 5:27 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/9/10 Stefan Rohlfing stefan.rohlf...@gmail.com: @ Nicolas and ajuc Thank you very much for showing

Some Problem with Recursion

2010-09-09 Thread Stefan Rohlfing
In order to get some more insight into recursion I wrote the following function but ended up in confusion: (defn prefix-postfix [expr] (if (coll? expr) (let [ [op arg1 arg2] expr] [ (prefix-postfix arg1) (prefix-postfix arg2) op])) expr) I expected the result to be a vector, such

Re: Some Problem with Recursion

2010-09-09 Thread Stefan Rohlfing
The indentation was correct by got messed up when I copying the code. This is how I interpret the function: 'expr' is only returned if (coll? expr) returns 'false', with is not the case with an argument such as '(+ 2 4). Next, this expression is destructured in the 'let' and 'prefix- postfix

Is Advanced Destructuring Considered Idiomatic?

2010-05-21 Thread Stefan Rohlfing
This site http://paste.lisp.org/display/97057 shows various examples of destructuring in Clojure ranging from basic to advanced. I managed to follow the more basic examples, but then got quickly lost when I looked at this one: (let [ [{a :a b :b c :c :as m :or {a 100 b 200}} [p q r s] ] [{:a 5

Re: Problem with Destructuring in A Function Call

2010-04-16 Thread Stefan Rohlfing
Your explanations from different angles of the problem were really helpful. I now have a much better picture of what is going on during destruturing. Thank you very much! Stefan -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group,