@ 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
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,
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
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 |
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.
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
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
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
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 =
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 -
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
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
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
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
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
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]
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)
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
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
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))
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
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
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
, 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
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
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
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
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
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:
:
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
,
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
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
:
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
,
;; :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
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
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
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
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.
@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
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
@ 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)
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
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
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
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
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,
46 matches
Mail list logo