11 11:02 AM
To: clojure@googlegroups.com
Subject: Re: Repeating a vector n times
Damn, Meikel's solution is better, I was thinking:
(apply concat (repeat n xs))
On Wed, Jul 13, 2011 at 10:54 AM, Bhinderwala, Shoeb
wrote:
I have to write a function that will take a vector as input,
I have to write a function that will take a vector as input, repeat the
elements multiple times and return back a single vector of the repeated
items. I came up with the following but am wondering if there is a
better or simpler way to write this:
(def xs ["a" "b" "c"])
(defn repeat-vec-n
[xs
PM
To: Clojure
Subject: Re: Data filtering function
(map #(get % ["45"]) d)
On Jul 5, 12:49 pm, "Bhinderwala, Shoeb"
wrote:
> I need help to write a small filtering function. Given the following
> definitions:
>
> (def m1
> {["45"] {:a 45 :b "d
I need help to write a small filtering function. Given the following
definitions:
(def m1
{["45"] {:a 45 :b "day1"}
["55"] {:a 55 :b "day1"}
["25"] {:a 25 :b "day1"}
["15"] {:a 15 :b "day1"}
["10"] {:a 10 :b "day1"}})
(def m2
{["45"] {:a 45 :b "day2
Here is another way:
(defn f [xs]
(and
(= 1 (first xs))
(apply = (map - (rest xs) xs
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of David Nolen
Sent: Friday, July 01, 2011 3:51 PM
To: clojure@googlegroups.
Hi Alan
I really liked the way you kept refactoring the original solution by Huahai to
make it more and more logical and elegant. I verified that each refactored
function produced the correct results.
Thanks for sharing your valuable thoughts and techniques.
Shoeb
-Original Message-
F
Thanks to all for the excellent and quick responses.
David - you are right the variable should be called product not sum. This is
just some poorly written Java code that I am translating to Clojure.
Justin - thanks for the idea on how to visualize such algorithms and the
picture you shared.
-
Hi
I have been learning clojure for some time but am a bit stumped when
translating code with nested for loops.
Can someone help me to translate the following java code to clojure
elegantly:
The inputs are two arrays of type double of the same length -
dailyValues and totalValues. The output i
:51 PM, Bhinderwala, Shoeb
wrote:
> What is the workaround in Clojure for:
>
> (/ 1M 3M)
>
> I am reading data from the database which by default comes in as BigDecimal
> (through the JDBC driver and Clojure SQL). When I perform calculations on
> them including division with t
What is the workaround in Clojure for:
(/ 1M 3M)
I am reading data from the database which by default comes in as
BigDecimal (through the JDBC driver and Clojure SQL). When I perform
calculations on them including division with the '/' operator I get
frequent ArithmeticExceptions based on my da
Thanks Meikel. This did exactly what I wanted. Thanks for your efforts.
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of Meikel Brandmeyer
Sent: Tuesday, June 14, 2011 7:25 AM
To: clojure@googlegroups.com
Subject: Aw: Vim Nailgun se
Thanks Baishmpayan. The link to the discussion thread you sent is very
enlightening for a new comer to Clojure.
-Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of Baishampayan Ghose
Sent: Monday, June 13, 2011 2:41 AM
To: clojure@googlegroups.c
To start thinking functionally, I would also highly recommend reading the book
Structure and Interpretation of Computer Programs:
http://mitpress.mit.edu/sicp/
http://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs
This book is available freely at the above sites. A b
Thanks Phil for the good work.
Emacs v23 didn't work for me in either Windows XP or Windows 7.
So, I searched and found Emacs 24 at:
http://code.google.com/p/emacs-for-windows/updates/list
clojure-jack-in with Emacs 24 worked seamlessly with Windows 7 (64 bit).
With Windows XP, clojure-jac
ject: Re: Emacs - marmalade package install and .emacs file entries
On Jun 6, 8:39 am, "Bhinderwala, Shoeb"
wrote:
> (add-to-list 'load-path "~/.emacs.d/elpa/clojure-mode-1.9.2/")
> (require 'clojure-mode)
>
> If I don't add the above entry clojure m
Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of
Phil Hagelberg
Sent: Monday, June 06, 2011 4:40 PM
To: Clojure
Subject: Re: Emacs - marmalade package install and .emacs file entries
On Jun 6, 8:39 am, "Bhinderwala, Shoeb"
wrote:
> (add-to-lis
ure?
Thanks
Shoeb
-Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of
Phil Hagelberg
Sent: Monday, June 06, 2011 12:16 AM
To: Clojure
Subject: Re: swank-clojure/lein/emacs
On Jun 5, 9:09 am, "Bhinderwala, Shoeb"
wrote:
> I inst
I am new to emacs and not sure how to automatically get the right
entries created in .emacs file after I install packages from marmalade.
Once I install a package using marmalade (e.g. clojure-mode-1.9.2) I
have to manually edit my .emacs file to add a "load-path" and "require"
entry:
Example ent
@googlegroups.com on behalf of Ambrose Bonnaire-Sergeant
Sent: Sun 6/5/2011 3:56 PM
To: clojure@googlegroups.com
Subject: Re: swank-clojure/lein/emacs
On Mon, Jun 6, 2011 at 3:46 AM, Bhinderwala, Shoeb <
sabhinderw...@wellington.com> wrote:
>
> Exception in
l Message-
From: clojure@googlegroups.com on behalf of Vijay Kiran
Sent: Sun 6/5/2011 12:42 PM
To: clojure@googlegroups.com
Subject: Re: swank-clojure/lein/emacs
I don't think you need to add the :dev-dependency, can you try again by
removing the line ?
./vijay
On Jun 5, 2011, at 6:09 PM,
I am struggling to setup swank-clojure and connect emacs with a lein
swank session.
I am on Windows XP. I followed the instructions at:
http://clojure02.managed.contegix.com/display/doc/Getting+Started+with+E
macs
I installed clojure-mode from marmalade. I added the following to my
.emacs fil
uot;window" of Emacs.
For color modes I use a Mac, so on the Terminal I use the Solarized Dark
theme, so it is used for Emacs as well.
Make sure that you either change to the directory in which you have the
lein project before you call clojure-jack-in.
./Vijay
On Jun 3, 2011, at 9:26 PM,
I am extremely new to Emacs. Been a long time Vim user.
I have installed Clojurebox and am able to get it running easily. Can
someone help me with the following:
1. I have a leningen project that I am working with. I usually do a lein
repl in the project directory and all the jars in the lib pat
I am trying to install jark on a Linux server and running into issues. I
am trying to follow the exact instructions as mentioned on the website:
http://icylisper.in/jark/start.html
I added the following bin directory to my PATH variable:
/home/BhindSA/bin
I downloaded jark-0.3 and copied it to
This is related to my multi-level bucketing problem which I am starting
new thread.
The code is at:
https://gist.github.com/952861
I am referring to the sum-by function which was provided by fellow
clojurer in this group. It choked when I passed in data of size one
million - meaning I didn't
Whoa! Thanks Juan. I will start to understand/analyze this...
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On
Behalf Of JuanManuel Gimeno Illa
Sent: Tuesday, May 03, 2011 11:40 AM
To: clojure@googlegroups.com
Subject: Re: RE: Multi-level buc
Hi Miki
What you provided is an amazing piece of code. I need a lot more time to
understand how it works since it uses so many higher order functions.
I have uploaded my original problem code base and your solution at:
https://gist.github.com/952382
This is just a simplified vers
Hi fellow clojurers:
I need help to group my data at multiple levels (currently 4) using a
tree structure and perform aggregate calculations at each level.
I have the below clojure code to generate a list of test records for me
(using the get-rec function).
(def reg-cntry-list
{"America" ["US
data-override
{2 {:id 2 :a2 5534 :a3 5576 :a4 5587}
3 {:id 3 :a2 5584 :a3 5586 :a4 5563}
12 {:id 12 :a2 5593 :a3 5512 :a4 5539}
13 {:id 13 :a2 5509 :a3 5539 :a4 5592}})
(merge data-orig data-override)
On Apr 26, 5:23 am, "Bhinderwala, Shoeb"
w
Thanks Baishampayan, Meikel, pepijn, and Jonathan.
The use of partition-by function does solve this very elegantly.
Below is the list of solutions I have received:
(defn merge-data [data1 data2]
(map first (partition-by :id (sort-by :id (concat data2 data1)
(defn merge-data2
Can someone help me write a merge function between two maps? My problem
is as follows:
I have original data in a map:
(def data-orig
'({:id 2 :a2 34 :a3 76 :a4 87},
{:id 3 :a2 30 :a3 38 :a4 39},
{:id 5 :a2 67 :a3 32 :a4 38},
{:id 4 :a2 10 :a3 73
Your function objects-at is correct but you have mixed up keywords and
strings in the definitions. Try the following:
(def *objects* '(:bottle :bucket :frog :chain))
(def *object-locations* {:bottle 'living-room, :bucket 'living-room,
:chain 'garden, :frog 'garden})
(defn objects-at [loc objs ob
(Sent the below email earlier but for some reason didn't make it to the list)
I wasn't aware of the group-by function. Being new to clojure, I spent a lot of
time coming up with my complex function. Seeing the one line solution really
blew me away. Thanks!!
Follow up questions on my problem (my
I wasn't aware of the group-by function. Being new to clojure, I spent
hours coming up with my complex function. Seeing the one line solution
really blew me away. Thanks!!
Follow up questions on my problem (my code again first):
;data is a list of records (maps)
(def data '({:a1 2 :a2 34 :a3 76 :
I am a beginner in Clojure.
I have a list of maps:
(def p '({:a 1 :b 2 :c 4}, {:a 2 :b 3 :c 5}, {:a 3 :b 4 :c 6}))
How do I add up all the :b values in the map? Result should be 9
(=2+3+4)
I know I should be using one of the higher level functions like apply,
reduce and combine it with a custom
[mailto:clojure@googlegroups.com] On
Behalf Of David Nolen
Sent: Wednesday, April 13, 2011 4:01 PM
To: clojure@googlegroups.com
Subject: Re: Creating defrecords from results of a sql query
On Wed, Apr 13, 2011 at 3:43 PM, Bhinderwala, Shoeb
wrote:
I am considering moving the results of with
I am considering moving the results of with-query-results into
defrecords. What is the best way to achieve this?
I wrote the following but it hits the limitation of 20 parameters and I
get an exception:
(defrecord PerfRecord [perf-dt grp-id sec-id asset-class beg-mv-base
end-mv-base
need tuning and optimization. Can clojureql
help with this?
-Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of
Alan
Sent: Thursday, March 17, 2011 1:12 PM
To: Clojure
Subject: Re: strint and macro expansion
On Mar 17, 8:34 am, "Bhinderw
I have the following definitions and am trying to use the strint macro
(<<) to perform string substitutions.
test1=>(use 'clojure.contrib.strint)
test1=> (def m {:XYZ 1, :ABC 2})
test1=> (def q "select ~(:XYZ m) from ~(:ABC m)")
The following works when I specify my string directly:
test1=> (<<
39 matches
Mail list logo