On Fri, Jun 17, 2011 at 12:58 AM, Ryan Twitchell metatheo...@gmail.com wrote:
Just for reflection:
What would you do with an existing class which had a getName() method,
when you suddenly realized you wanted getFirstName() and getLastName()
instead? Or the reverse?
If you can't refactor the
Hi everyone. Ran into an interesting case here when trying stuff out
in the REPL.
user= (Math/sqrt 4)
2.0
user= (map #(Math/sqrt %) (range 1 10))
(1.0 1.4142135623730951 ..)
user= (map Math/sqrt (range 1 10))
java.lang.Exception: Unable to find static field: sqrt in class
java.lang.Math
On Fri, Jun 17, 2011 at 2:59 AM, de1976 davidescobar1...@gmail.com wrote:
Hi everyone. Ran into an interesting case here when trying stuff out
in the REPL.
user= (Math/sqrt 4)
2.0
user= (map #(Math/sqrt %) (range 1 10))
(1.0 1.4142135623730951 ..)
user= (map Math/sqrt (range 1 10))
Surely you must have rooted my box.
That is my code more or less :)
To the op:
Use the immutable structures if possible.
Make your types as basic as possible.
Use Clojure's higer order functions reduce, map etc
I consider loop as a last resort.
Then your solution will closely match the
On 17 Jun, 2011, at 9:20 , Ken Wesson wrote:
Shouldn't it be possible to apply Math/sqrt directly? If I use a
function from the clojure.core, I can do it:
user= (map str (range 1 10))
(1 2 3 4 5 6 7 8 9)
Java methods aren't first-class functions, so they can't be mapped, or
used directly
Interesting points. Thanks for the pragmatic advice.
Your statement With that in mind,
note that such compositions usually address the problems of
structuring a program in some new way, often at run time. Functional
programming has lots of its own solutions for such problems sums up my
issue -
I apologise for the stupidity of this question in advance.
Just want to clarify. The jvm is great for other languages to be
hosted on clojure, jruby, scala, jython...etc. But what would be
really cool is if we could use the jvm to create interoperability
between the languages so that clojure
On Fri, Jun 17, 2011 at 6:09 AM, flebber flebber.c...@gmail.com wrote:
I apologise for the stupidity of this question in advance.
Usually, the only stupid question is the one you didn't ask.
Just want to clarify. The jvm is great for other languages to be
hosted on clojure, jruby, scala,
No one question is stupid. Any jvm language can use jvm byte code.
For example you can use Java libraries in Scala, Clojure,..
Of course sometimes it is not natural fit.
For example if you use Scala in Java you have to know Scala compiler
will generate set/get methods.
Zlaja
On Fri, Jun 17, 2011
On Thu, Jun 16, 2011 at 6:07 PM, octopusgrabbus
octopusgrab...@gmail.com wrote:
This Clojure program:
ns test-csv
(:require [clojure.contrib.string :as str])
(:import (java.io BufferedReader FileReader StringReader))
(:use clojure-csv.core))
(defn process-file [file-name]
On Thu, Jun 16, 2011 at 9:51 AM, Tassilo Horn tass...@member.fsf.org wrote:
Hi all,
I have some functions that use destructuring on a map parameter, and it
seems I have a false assumption on the workings. Take for example this
one:
(defn foo
[{:keys [a b]
:or {a 1 b 2}
:as all}]
Thanks for the reply. In this instance, what's the syntax for map? I'm
trying in REPL and getting a wrong number of arguments (1) passed to
core$map.
On Jun 17, 7:11 am, Ken Wesson kwess...@gmail.com wrote:
On Thu, Jun 16, 2011 at 6:07 PM, octopusgrabbus
octopusgrab...@gmail.com wrote:
On Jun 17, 8:39 pm, Zlatko Josic zlatko.jo...@gmail.com wrote:
No one question is stupid. Any jvm language can use jvm byte code.
For example you can use Java libraries in Scala, Clojure,..
Of course sometimes it is not natural fit.
For example if you use Scala in Java you have to know Scala
Hi
On 17 June 2011 00:07, octopusgrabbus octopusgrab...@gmail.com wrote:
This Clojure program:
ns test-csv
(:require [clojure.contrib.string :as str])
(:import (java.io BufferedReader FileReader StringReader))
(:use clojure-csv.core))
[...]
I am having trouble figuring out where to
I'm used to using the Python csv package and how that returns lines
from a csv. I could not get clojure-csv to split up the line the way I
wanted, and also thought about how to clojure.string/split the line.
Right now at the repl, I cannot figure out the syntax just to use map
on a sequence of
I'm trying this in REPL
timmy= (def ox [1 2 3 4])
#'timmy/ox
timmy= ox
[1 2 3 4]
timmy= (map #(reduce str/split (seq ox) #,))
java.lang.IllegalArgumentException: Wrong number of args (1) passed
to: core$map (NO_SOURCE_FILE:0)
t
On Jun 17, 8:55 am, octopusgrabbus octopusgrab...@gmail.com wrote:
On Fri, Jun 17, 2011 at 8:47 AM, flebber flebber.c...@gmail.com wrote:
On Jun 17, 8:39 pm, Zlatko Josic zlatko.jo...@gmail.com wrote:
No one question is stupid. Any jvm language can use jvm byte code.
For example you can use Java libraries in Scala, Clojure,..
Of course sometimes it is not
On Fri, Jun 17, 2011 at 8:57 AM, octopusgrabbus
octopusgrab...@gmail.com wrote:
I'm trying this in REPL
timmy= (def ox [1 2 3 4])
#'timmy/ox
timmy= ox
[1 2 3 4]
timmy= (map #(reduce str/split (seq ox) #,))
java.lang.IllegalArgumentException: Wrong number of args (1) passed
to: core$map
No, I did'nt mean that. I just talk about if it can be done easily in sence
of host language.
Write some a code in JRuby, make jar and try it. It's nothing new. Every jvm
language use
existing libraries. If you want to write a swing application you will use
swing library, which is
allready writen
Many thanks. I didn't recognize the % symbol is used similarly to the
way it's used in printf and constructing SQL query string.
On Jun 17, 9:07 am, Ken Wesson kwess...@gmail.com wrote:
On Fri, Jun 17, 2011 at 8:57 AM, octopusgrabbus
octopusgrab...@gmail.com wrote:
I'm trying this in REPL
On Fri, 17 Jun 2011 03:09:46 -0700 (PDT)
flebber flebber.c...@gmail.com wrote:
I apologise for the stupidity of this question in advance.
Just want to clarify. The jvm is great for other languages to be
hosted on clojure, jruby, scala, jython...etc. But what would be
really cool is if we
non-lazy version:
(map #(vec (.split % ,))
(vec (.split (slurp /tmp/foo.csv) \n)))([foo
bar] [fu bor])
On Fri, Jun 17, 2011 at 2:39 PM, octopusgrabbus octopusgrab...@gmail.comwrote:
Thanks for the reply. In this instance, what's the syntax for map? I'm
trying in REPL and
This question is more about knowing what is returned after applying a
function and the best functional programming practices to use in
obtaining particular data in what has been returned.
So, given this program:
(ns test-csv
(:gen-class)
(:import (java.io BufferedReader FileReader
Some resources, in case they help:
1. http://clojuredocs.org/ has documentation for core and contrib, and often
has examples
http://clojuredocs.org/2. http://clojure.org has a lot of reading material
about the language, including a nice cheat sheet (
http://clojure.org/cheatsheet)
3.
parse-csv returns a sequence of vectors. The functional way of traversing
a sequence is using map:
(ns foo
(:gen-class)
(:use clojure-csv.core))
(defn process-file
Process csv file and prints first item in every row
[file-name]
(let [data (slurp file-name)
rows (parse-csv
On Thu, Jun 16, 2011 at 6:12 PM, Stuart Halloway
stuart.hallo...@gmail.com wrote:
Hi Gregg,
It appears that LocalServiceTestHelper's constructor takes an array
of LocalServiceTestConfig. Try
(def bar (LocalServiceTestHelper. (into-array LocalServiceTestConfig [foo])))
Stu
Hi Stu,
Would
Thanks for your answer. I remember the notes on clojure-csv saying it
employed lazy I/O. So, it looks like by using slurp, there is still
lazy-io going on.
On Jun 17, 10:46 am, Miki miki.teb...@gmail.com wrote:
parse-csv returns a sequence of vectors. The functional way of traversing
a sequence
In Java, varargs are actually converted to arrays at compile time. It is
really just some syntactic sugar allowing you to use nicer syntax for array
arguments, and you can pass the arguments as an array, or as a comma
delimited sequence of arguments.
On Fri, Jun 17, 2011 at 10:57 AM, Gregg
flebber flebber.c...@gmail.com writes:
On Jun 17, 8:39 pm, Zlatko Josic zlatko.jo...@gmail.com wrote:
No one question is stupid. Any jvm language can use jvm byte code.
For example you can use Java libraries in Scala, Clojure,..
Of course sometimes it is not natural fit.
For example if you
Also, you don't want to simply split the CSV into lines by looking for
newlines. CSVs can contain newlines quoted in fields, so you need to
actually parse the CSV with quoting to figure out the line breaks for
the file format and ignore the line breaks in the fields.
- David
On Fri, Jun 17,
It's practical. I had a project with Java (source), JRuby, and Clojure all
interacting.
-S
On Friday, June 17, 2011 8:47:09 AM UTC-4, flebber wrote:
So it is possible but not practical to call jruby from within a
clojure script?
--
You received this message because you are subscribed to
this page explains a bunch of ways of calling jruby from java:
https://github.com/jruby/jruby/wiki/RedBridge
think i would have to have pretty good reason before doing this (like
wanting to use jruby as a user scripting language in a clojure app
maybe)...
On Fri, Jun 17, 2011 at 11:08 AM, Phil
Thanks. It really is amazing how non functional Java is. Makes me
glad there are now languages that do their best to correct that.
--
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
Thanks for your answer, David:
Eventually, I came back from reading a .csv file using a generic
method to closure-csv, and got help wrapping my mind around the data I
was getting back from closure-csv/parse and how to pull that apart to
get what I wanted.
I was also stuck on the notion of having
Hi Miki,
Thats an interesting idea that I had not thought of. It nicely
encapsulates everything in one package.
Thanks!
Damon
On Jun 16, 6:15 pm, Miki miki.teb...@gmail.com wrote:
One more option is to embed the jar in base64 encoding in a script, extract
the jar to a temp location and run it.
On Fri, Jun 17, 2011 at 10:17 AM, Mark Rathwell mark.rathw...@gmail.com wrote:
In Java, varargs are actually converted to arrays at compile time. It is
really just some syntactic sugar allowing you to use nicer syntax for array
arguments, and you can pass the arguments as an array, or as a
Yeah, not sure which is better, Java's or C#'s varargs, but it does make
things nicer at times. In C#, the method signature signature screams I AM
passing an array, but you can pass arguments either way as in Java.
C#:
public void UseVarargs(params int[] args)
{
// Do
If you use Cake to build your project, then cake bin will create a standalone
executable.
Cheers,
-Michael
On Jun 16, 2011, at 2:08 PM, Damon Snyder wrote:
Hi Everyone,
I'm have a side project that I'm working on that I want to distribute
as a standalone script. This is probably best
Hello,
What is wrong in this function?
(defn testmap []
(do
(map #(fn1 %)
'(a b c))
(map #(fn2%)
'(1 2 3))
))
If fn1 = fn2 = println
the result is
(1
2
nil 3
nil nil)
I expected this result
a
b
c
1
2
3
Thanks
--
You received this message because you are subscribed
Check your spaces...
2011/6/17 FD fabien.dub...@scarlet.be:
Hello,
What is wrong in this function?
(defn testmap []
(do
(map #(fn1 %)
'(a b c))
(map #(fn2%)
'(1 2 3))
))
If fn1 = fn2 = println
the result is
(1
2
nil 3
nil nil)
I expected this result
a
b
c
Hi all,
I am writing a library [1] which has only one function that should be
exposed to users. I'd like to be able to test all of the other functions,
which are marked private with defn-. Of course, these functions are
inaccessible from the testing namespace (I'm using the testing boilerplate
On Fri, Jun 17, 2011 at 11:13 AM, FD fabien.dub...@scarlet.be wrote:
(map #(fn2%)
Needs a space between fn2 and %
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. --
On Fri, Jun 17, 2011 at 2:13 PM, FD fabien.dub...@scarlet.be wrote:
Hello,
What is wrong in this function?
(defn testmap []
(do
(map #(fn1 %)
'(a b c))
(map #(fn2%)
'(1 2 3))
))
1) for is lazy, its value is a LazySeq and the contents are only
evaluated at need
2)
Ken Wesson kwess...@gmail.com writes:
Hi Ken!
That somehow makes sense, but is there some way to get the complete
map with defaults applied, too?
(defn foo
[{:keys [a b]
:or {a 1 b 2}
:as all}]
(let [all (merge {:a 1 :b 2} all)]
[(hash-map :a a :b b) all]))
Of course
I was going to bring up RedBridge as well. Here is Yoko Harada's
presentation from RubyConf 2010. Around 14:07 she starts talking about
examples of embedding JVM languages within one another (one of the
examples is embedding the DataMapper library into a Clojure program).
So, it's definitely
Thanks
I change the function with this one
(defn testdoseq []
(do
(doseq [x '(a b c)]
(fn1 x)
)
(doseq [x '(1 2 3)]
(fn2 x)
)
))
On 17 juin, 20:26, Aaron Cohen aa...@assonance.org wrote:
On Fri, Jun 17, 2011 at 2:13 PM, FD fabien.dub...@scarlet.be wrote:
Benjamin Esham bdes...@gmail.com writes:
Hi Benjamin,
(defn refer-private [ns]
(doseq [[symbol var] (ns-interns ns)]
(when (:private (meta var))
(intern *ns* symbol var
As he says, this is slightly evil, and I would never recommend it for
any purpose
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
Hi all,
I have some code in Scheme that I'm converting over to Clojure. It frequently
uses a dispatching pattern that's very similar to multimethods, but with an
inverted approach to the matching predicates. For example, there a generic
function assign-operations. The precise implementation
On Fri, Jun 17, 2011 at 2:31 PM, Tassilo Horn tass...@member.fsf.org wrote:
Ken Wesson kwess...@gmail.com writes:
Hi Ken!
(defmacro defnm [name argvec body]
`(defn ~name ~argvec
(let ~(vec
(apply concat
(for [a argvec :when (and (map? a) (:or a) (:as
I just have to add that your code is really not idiomatic for
Clojure. The do is not required here because there is an implicit do
around the body of every fn (including one created with defn). Also,
it's somewhat bad form to vertically align parentheses in Lisps.
Finally, if you want to place
On Jun 17, 2011, at 1:21 PM, Benjamin Esham wrote:
I am writing a library [1] which has only one function that should be
exposed to users. I'd like to be able to test all of the other functions,
which are marked private with defn-. Of course, these functions are
inaccessible from the testing
On Fri, Jun 17, 2011 at 2:51 PM, Bhinderwala, Shoeb
sabhinderw...@wellington.com 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
Excellent screencast.
On Thu, Jun 16, 2011 at 11:16, Sam Aaron samaa...@gmail.com wrote:
Hi there,
I just finished making a screencast primarily for new Overtone users on how
to get set up with Emacs as a primary editor:
http://vimeo.com/25190186
It turns out that this should be pretty
Thanks Ken. That did the trick.
-Original Message-
From: clojure@googlegroups.com [mailto:clojure@googlegroups.com] On Behalf Of
Ken Wesson
Sent: Friday, June 17, 2011 3:17 PM
To: clojure@googlegroups.com
Subject: Re: BigDecimal Division - Arithmetic Exception
On Fri, Jun 17, 2011 at
I found on Twitter the implementation of the latest stupid algorithm: sleep
sort. The idea behind sleep sort is that you sleep in parallel for a number
of second equal to the value of each cell and emit them as you finish
sleeping. The algorithm is said to run in O(lol^n)
The canonical
Phil,
This works for me! Thanks!
Jeff
On Sun, Jun 12, 2011 at 7:51 PM, Phil Hagelberg p...@hagelb.org wrote:
On Jun 12, 10:58 am, Mark Engelberg mark.engelb...@gmail.com wrote:
I take that back (I had edited the wrong file, which wasn't the one my
emacs was using).
I get the error Not
Mark,
I got this same error when I copied and pasted the clojure-jack-in
function from gmail. I had to remove newlines from
(search-backward slime-load-hook)
and
(slime-connect localhost clojure-swank-port)
Hope that helps,
Jeff
On Sun, Jun 12, 2011 at 8:50 PM, Mark Engelberg
Not my idea, can't recall where I've seen it first (nvidia driver?)
--
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 - please be patient with
So, it looks like by using slurp, there is still
lazy-io going on.
I don't think slurp is lazy.
user= (doc slurp)
-
clojure.core/slurp
([f opts])
Reads the file named by f using the encoding enc into a string
and returns it.
nil
user=
--
You received this
(defn sleepsort [ s] (deref (reduce #(do (await (deref %2)) (deref
%2)) nil (doall (map #(future (Thread/sleep (* %1 100)) (send %2 conj
%1) %2) s (repeat (agent [])))
user=(sleepsort 2 1 6 5)
[1 2 5 6]
By having the future return the agent, the reduce then calls deref on
all the futures
On Jun 17, 2011, at 3:44 AM, Konrad Hinsen wrote:
Java methods aren't even first-class objects (nor, in fact, objects at all)
in the Java world. Clojure can hardly do better than Java in unifying things
at the JVM level. The one thing that you can do with a method in Java is call
it, and
If you're in a repl*, why not simply use (in-ns namespace) ?
Of course, this wont work in all cases (e.g. testing private functions from
two different namespaces).
In that case, I find it simpler to remove the '-' temporary. When you're
finished, it really doesn't take that much effort to add them
What is the best way to remove the duplication in these two functions?:
(defn- next-day-of-week-in-future [day-num]
(find-first #(= day-num (.. % dayOfWeek get)) (today+all-future-dates)))
(defn- next-day-of-month-in-future [day-of-month]
(find-first #(= day-of-month (.. % dayOfMonth get))
The best way to test private methods is to have very few of them. Test the
ones you do have via the public API, and if you have too many then IMHO they
should be public methods in a separate namespace. Separate the two
namespaces by responsibility. I do this all the time on OOP languages, and
On Fri, Jun 17, 2011 at 7:32 PM, Alex Baranosky
alexander.barano...@gmail.com wrote:
What is the best way to remove the duplication in these two functions?:
(defn- next-day-of-week-in-future [day-num]
(find-first #(= day-num (.. % dayOfWeek get)) (today+all-future-dates)))
(defn-
Awesome!
I am still really a beginner with macros. I had tried to get one to work,
but wasn't sure if it was possible. Thanks!
On Fri, Jun 17, 2011 at 8:59 PM, Ken Wesson kwess...@gmail.com wrote:
On Fri, Jun 17, 2011 at 7:32 PM, Alex Baranosky
alexander.barano...@gmail.com wrote:
What is
Thanks a lot for the link to the paper about FRP! My personal thinking
is going 90% in the same direction that the paper describes. I am
happy to see that somebody else did the hard work of writing it
down :)
Is anybody aware of an implementation of such an approach for Clojure?
--
You received
On 18 Jun, 2011, at 1:12 , Michael Gardner wrote:
On Jun 17, 2011, at 3:44 AM, Konrad Hinsen wrote:
Java methods aren't even first-class objects (nor, in fact, objects at all)
in the Java world. Clojure can hardly do better than Java in unifying things
at the JVM level. The one thing that
69 matches
Mail list logo