That's great. I've also noticed the sample still uses defstruct which is
made obsolete by defrecord.
On Tue, Jun 12, 2012 at 7:59 AM, Baishampayan Ghose wrote:
> > Can you elaborate some suggestions?
>
> I have updated the Ants sim code to use the "idiomatic" JVM inter-op
> constructs and made so
Hi,
To contrast our experiences of the language and the different approaches to
deal with some problems:
On Sun, Jun 10, 2012 at 4:47 AM, Kurt Harriger wrote:
> Many will say that side-effecting functions are more difficult to test
> then pure functions... However after writing about 4000 lines
On Tue, Jun 12, 2012 at 1:37 PM, Yann Schwartz wrote:
> That's great. I've also noticed the sample still uses defstruct which is
> made obsolete by defrecord.
While I agree that one could use a record in place of a struct, I
don't think structs are "obsolete", at least not officially.
Regards,
B
On Tue, Jun 12, 2012 at 2:08 AM, Frank Siebenlist
wrote:
> (-> 2
> (* 5)
> (+ 3))
It also resembles a waterfall (not very friendly term in our
profession, but fits well in this case) where the result of an earlier
computation is passed on down the stack. It also works very similarly
to the
Hello forum,
Given
(def m (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e))
,
(nth m 0)
throws 'UnsupportedOperationException nth', while
(first m) ; -> [1 :a]
(next m) ; -> ([2 :b] [3 :c] [4 :d] [5 :e])
(nthnext m 1) ; -> ([2 :b] [3 :c] [4 :d] [5 :e])
.
How do you think about nth accepts maps
I've opened JIRA CLJ-1011.
On Sunday, June 10, 2012 1:16:55 PM UTC+1, Philip Aston wrote:
>
> Current behaviour of clojure.data/diff:
>
> => (diff {:a false} {:a true})
> (nil {:a true} nil)
> => (diff {:a false} {:a nil})
> (nil nil nil)
>
> With patch:
>
> => (diff {:a false} {:a true})
> ({:a
While it would be possible to support it, I don't think that it makes sense
for maps (or sets).
While first and next need to be supported to make maps and sets sequable, I
don't think that conceptually the elements are ordered.
Cheers,
Chris
On 12 June 2012 11:03, Yoshinori Kohyama wrote:
> H
Hi,
Am Dienstag, 12. Juni 2012 12:10:08 UTC+2 schrieb Chris Ford:
>
> While first and next need to be supported to make maps and sets sequable,
> I don't think that conceptually the elements are ordered.
Take care! Neither maps nor sets (nor vectors for that matter) support
first and next! The
Hi,
Am Dienstag, 12. Juni 2012 10:24:31 UTC+2 schrieb Baishampayan Ghose:
>
>
> While I agree that one could use a record in place of a struct, I
> don't think structs are "obsolete", at least not officially.
>
>
>From http://clojure.org/datatypes:
Overall, records will be better than structmap
I'm fairly new to Clojure and Java. When I try to call Clojure code
from Java, I get an error "java.io.FileNotFoundException: Could not
locate Clojure resource on classpath: bar.clj".
I've created a simple project in Eclipse with one Java file:
package sample;
import clojure.lang.*;
public class
Meikel is quite right. I should have said that maps and sets support seq...
I guess the question should then be, should nth call seq on its argument?
On 12 June 2012 11:31, Meikel Brandmeyer (kotarak) wrote:
> Hi,
>
> Am Dienstag, 12. Juni 2012 12:10:08 UTC+2 schrieb Chris Ford:
>
>> While firs
>> While I agree that one could use a record in place of a struct, I
>> don't think structs are "obsolete", at least not officially.
>>
>
> From http://clojure.org/datatypes:
>
>>> Overall, records will be better than structmaps for all
>>> information-bearing purposes, and you should move such str
why can't I use the interface as function argument instead of the
concrete class (record)?
example: (defprotocol IPiece
blah blah blah)
(defrecord ChessPiece
IPiece
blah blah blah)
(defrecord CheckersPiece
IPiece
blah blah blah)
(defn move [^IPiece p] ;will complain th
"Jim - FooBar();" writes:
> why can't I use the interface as function argument instead of the
> concrete class (record)?
>
> example: (defprotocol IPiece
> blah blah blah)
>
> (defrecord ChessPiece
> IPiece
> blah blah blah)
>
> (defrecord CheckersPiece
> IPiece
> blah blah
aaa ok I see...
however I only want to do this to avoid a specific reflection call...you
see my move function take either any type that satisfies IPiece and so
at each call reflection is needed to decide which one to use...I'd like
to say in the argument that what is coming is a IPiece so stop
Thanks Tassilo,
your suggestion of fully qualifying the protocol worked like a charm! I
managed to eliminate my last 2 reflective calls on the whole
namespace... this is good stuff!
Jim
On 12/06/12 12:57, Jim - FooBar(); wrote:
aaa ok I see...
however I only want to do this to avoid a spe
On Tue, Jun 12, 2012 at 8:50 AM, Denis Vulinovich
wrote:
> My Java classpath (in Windows) is C:\dev\vaadin\sample.
It misses "classes" subdirectory.
Also, I don't think you need lein for the example. Write a clj script
and have it loaded/compiled by RT.loadResourceScript.
If you're in Eclipse,
On Mon, Jun 11, 2012 at 9:52 PM, Cédric Pineau wrote:
> Also, can someone point me to a ~/lein/profiles.clj sample or a complete
> lein2 documentation ?
Just to add to Phil's answer:
The profiles in lein2 are just a map (obviously, isn't it?) where the
key is the name of the profile and the val
I have started seeing java.lang.ClassCastException when compiling in
advanced mode.
Compilation is fine with simple optimisations.
This happens with source code that previously did not complain...
I am wondering if this might be related to :
https://groups.google.com/d/topic/clojure/NHIzoUz0wm
"Jim - FooBar();" writes:
Hi Jim,
> however I only want to do this to avoid a specific reflection
> call... you see my move function take either any type that satisfies
> IPiece and so at each call reflection is needed to decide which one to
> use...
I don't get you. If IPieces can be moved, t
On 12/06/12 13:16, Tassilo Horn wrote:
I don't get you. If IPieces can be moved, then move should be a
protocol method declared in IPiece.
No what i have in IPiece is 'updatePosition' so each piece knows how to
update its position. THere is more to a move though. 'move' is a regular
function
Of course, I Just noticed that type-hinting 'p' renders the precondition
useless...an extra performance bonus!
Jim
On 12/06/12 13:26, Jim - FooBar(); wrote:
On 12/06/12 13:16, Tassilo Horn wrote:
I don't get you. If IPieces can be moved, then move should be a
protocol method declared in IPie
And when you say you have reflection warnings, can it be that you call a
protocol method foo with (.foo o) [note the .-syntax]...
I'm not sure what you mean...Of course I'm calling a protocol method
with (.update-position p coords) - with the '.'
How else can I call it?
Jim
On 12/06/12 13:28
Hi,
Am Dienstag, 12. Juni 2012 14:28:21 UTC+2 schrieb Jim foo.bar:
>
> Of course, I Just noticed that type-hinting 'p' renders the precondition
> useless...an extra performance bonus!
>
>
If update-position is a protocol function just call it without the dot.
Just like a normal function. Then a
That ticket has been resolved.
For your own issue, more details required. If you can isolate it, open a
ticket.
David
On Tue, Jun 12, 2012 at 8:16 AM, Dave Sann wrote:
> I have started seeing java.lang.ClassCastException when compiling in
> advanced mode.
>
> Compilation is fine with simple op
On 12/06/12 13:47, Meikel Brandmeyer (kotarak) wrote:
If update-position is a protocol function just call it without the
dot. Just like a normal function. Then any reflection will go away and
no type hint is needed.
WHAT??? Seriously??? I'll try it...
Jim
--
You received this message because
On 12/06/12 13:53, Jim - FooBar(); wrote:
On 12/06/12 13:47, Meikel Brandmeyer (kotarak) wrote:
If update-position is a protocol function just call it without the
dot. Just like a normal function. Then any reflection will go away
and no type hint is needed.
WHAT??? Seriously??? I'll try it...
If your namespace is sample.bar, shouldn't the load() call
"sample/bar.clj" instead of "bar.clj" ?
Le 12 juin 2012 à 12:39, Denis Vulinovich
a écrit :
> I'm fairly new to Clojure and Java. When I try to call Clojure code
> from Java, I get an error "java.io.FileNotFoundException: Could not
> l
"Jim - FooBar();" writes:
> No what i have in IPiece is 'updatePosition' so each piece knows how
> to update its position.
Ok.
>> And when you say you have reflection warnings, can it be that you call a
>> protocol method foo with (.foo o) [note the .-syntax]...
> I'msure you will understand if
"Jim - FooBar();" writes:
>>> If update-position is a protocol function just call it without the
>>> dot. Just like a normal function. Then any reflection will go away
>>> and no type hint is needed.
>>
>> WHAT??? Seriously??? I'll try it...
>
> OMG! You were right Meikel... I cannot believe this
"Jim - FooBar();" writes:
>> And when you say you have reflection warnings, can it be that you call a
>> protocol method foo with (.foo o) [note the .-syntax]...
>
> I'm not sure what you mean...Of course I'm calling a protocol method with
> (.update-position p coords) - with the '.'
> How else c
Is there any reason that (let [[x y :or {x 1 y 2}] nil] [x y]) can't work?
--
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
On Mon, Jun 11, 2012 at 1:46 PM, Phil Hagelberg wrote:
> On Mon, Jun 11, 2012 at 12:52 PM, Cédric Pineau
> wrote:
>> My question is with the lazy-test dependency. Do I really have to put it as
>> a project dependency ?
>> It doesn't seem to be on the lein-midje path when puting it in the
>> dev-
On 06/12/2012 12:05 PM, Phil Hagelberg wrote:
On Mon, Jun 11, 2012 at 1:46 PM, Phil Hagelberg wrote:
On Mon, Jun 11, 2012 at 12:52 PM, Cédric Pineau wrote:
My question is with the lazy-test dependency. Do I really have to put it as
a project dependency ?
It doesn't seem to be on the lein-midj
On Tue, Jun 12, 2012 at 9:11 AM, Daniel E. Renfer wrote:
> The issue here is that Midje and lein-midje don't need Lazytest for normal
> operation, only for the --lazytest support. What would be the proper way to
> specify that dependency without requiring that everyone that uses Midje also
> carry
Hi all,
Thank you for commenting, Chris and Meikel.
In my Clojure 1.3.0 REPL,
(def sm (sorted-map 0 {:name "Alice"} 1 {:name "Bob"} 2 {:name
"Charlie"}))
(loop [c sm acc []]
(if-let [[k v] (first c)]
(recur (next c) (conj acc (assoc v :id k)))
acc))
returns
[{:name "Alice",
On Tuesday, June 12, 2012 2:18:03 AM UTC-6, Christophe Grand wrote:
>
> Hi,
>
> To contrast our experiences of the language and the different approaches
> to deal with some problems:
>
> On Sun, Jun 10, 2012 at 4:47 AM, Kurt Harriger wrote:
>
>> Many will say that side-effecting functions are m
Hi,
As titled, I need to exclude certain dependencies from my final .jar
file (because those dependencies will already be there in the final
target Java environment). How can I do that? Thank you.
PS: I am using Leinengen 2
--
You received this message because you are subscribed to the Google
G
On Tue, Jun 12, 2012 at 9:59 AM, Warren Lynn wrote:
> As titled, I need to exclude certain dependencies from my final .jar
> file (because those dependencies will already be there in the final
> target Java environment). How can I do that? Thank you.
The uberjar task is designed to create jars me
On Tue, Jun 12, 2012 at 6:59 PM, Warren Lynn wrote:
> As titled, I need to exclude certain dependencies from my final .jar
> file (because those dependencies will already be there in the final
> target Java environment). How can I do that? Thank you.
I'm trying to figure out where you're heading
On Jun 12, 5:56 am, "Jim - FooBar();" wrote:
> On 12/06/12 13:53, Jim - FooBar(); wrote:
>
> > On 12/06/12 13:47, Meikel Brandmeyer (kotarak) wrote:
> >> If update-position is a protocol function just call it without the
> >> dot. Just like a normal function. Then any reflection will go away
> >>
On Mon, Jun 11, 2012 at 11:50 PM, Denis Vulinovich
wrote:
> RT.loadResourceScript("bar.clj");
You talk about putting the .class files on your classpath (modulo the
correction to add the classes subdirectory as Jacek noted) but you are
trying to load a source file (from the classpat
On Tue, Jun 12, 2012 at 8:41 PM, Sean Corfield wrote:
> As your Clojure code grows and depends on other libraries, you'll need
> to ensure those are also on your classpath (lib/*.jar from your
> Leiningen project).
lein2 doesn't use lib/* anymore. All's in ~/.m2/repository. You need
the classpat
Hi,
First a quick disclaimer. Those are my first steps in Clojure so I am
not be super accustomed to the language entire landscape and might
miss some basics here. However I was able to solve my first 4clojure
hard problem https://www.4clojure.com/problem/53 and have some second
thoughts after loo
Jay Fields writes:
Hi Jay,
> Is there any reason that (let [[x y :or {x 1 y 2}] nil] [x y]) can't
> work?
:or is only supported for map destructuring but you use sequence
destructuring.
user> (map #(let [{x :x, y :y :or {x 1, y 2}} %1]
[x y])
[{} {:x 17, :y 3} {:y 1}])
On 12/06/12 14:43, Tassilo Horn wrote:
"Jim - FooBar();" writes:
If update-position is a protocol function just call it without the
dot. Just like a normal function. Then any reflection will go away
and no type hint is needed.
WHAT??? Seriously??? I'll try it...
OMG! You were right Meikel...
On 12/06/12 19:41, Alan Malloy wrote:
It's not just less convenient, but genuinely incorrect to use dot-
notation for protocol functions. Not every class that satisfies the
protocol will be implementing the interface directly, and so dot-
notation will fail on them. The interface generated by def
Hello,
thank you very much for your answer, it is exactly what I was looking for !
Le vendredi 8 juin 2012 13:35:36 UTC+2, Gabo a écrit :
>
> Hello,
>
> I'm a beginner with Clojure and trying some basic stuff.
> I'm actually working on a simple function which would replace the nth
> element of a
Hi Marek,
I did what you said and I translated the prolog code to core.logic. Your
2 examples helped a lot and thanks again for that. The versionI've got
now is this:
---
(defn knight-moves [x y]
(let [
Nevermind...I found the namespace with these non-relational operators
and the code works like a charm!!! I am so happy... :-)
Jim
On 12/06/12 22:18, Jim - FooBar(); wrote:
Hi Marek,
I did what you said and I translated the prolog code to core.logic.
Your 2 examples helped a lot and thanks a
> As the name says uberjar is what you should be able to run with no
> worries about the classpath - all deps are included in the final jar.
> Since you asked to exclude some deps, you likely run the final jar in
> a kind of managed environment. Why are there some deps not the others?
> What
On Tue, Jun 12, 2012 at 3:00 PM, Warren Lynn wrote:
> I plan to deploy the jar as a lib in another Java framework. This clojure
> .jar file depends on some common lib (API kind of thing) that will be
> included in the Java framework itself so I don't want to include another
> copy.
>
> "uberjar" m
On Tue, Jun 12, 2012 at 12:28 PM, Tassilo Horn wrote:
> user> (map #(let [{x 0 y 1 :or {0 -1, 1 -2}} %1]
> [x y])
> [[] [10] [10 11]])
> ([nil nil] [10 nil] [10 11])
>
> I had expected it to return ([-1 -2] [10 -2] [10 11]).
It needs to be this:
user=> (map #(let [{x 0 y 1
On Mon, Jun 11, 2012 at 1:48 PM, Phil Hagelberg wrote:
> On Mon, Jun 11, 2012 at 9:36 AM, Phil Hagelberg wrote:
>> These will be removed once Central gets back to working order, but
>> they should help stem the flow of catastrophic build failures.
>
> While this will allow most builds to work, it
right, I know it's possible to do what you guys are describing. What I meant to
ask is, should :or be allowed in destructuring vectors? I can't see any reason
for it not to be allowed.
On Jun 12, 2012, at 7:10 PM, Sean Corfield wrote:
> On Tue, Jun 12, 2012 at 12:28 PM, Tassilo Horn wrote:
>>
If you don't need AOT then you can include the common lib in
> dependencies in the :dev profile.
>
> If you need AOT then you'll have to write a plugin that works like a
> more selective variant of uberjar.
>
> -Phil
>
I do need AOT, and I am not ready yet to write any plugins. Maybe I can
The dot firm is an explicit call to interop. Protocols are a clojure concept :)
The underlying mechanism happens to look like a Java interface today.
However you can expect to bypass some niceties by doing this.
This is what the JVM offers today to implementors. Might be different in
future releas
This is what I ended up with, which I think is relatively clear and
straightforward (but then, I'm not entirely unbiased :)
The algorithm is very close to what you described.
- Generate all sub-sequences of length > 1
- Filter to keep only increasing subsequences
- Tack on the empty sequence, wh
Nice. But I wonder if sorting and (count coll) actually forces the
algorithm to load everything into memory. My Clojure solution is more
convoluted (will post it later) and suffers the same due to a
recursive algorithm doing the transformation I described at the end.
However I think I have someth
forgot full listing:
scala> List[Int](6, 7, 8, 1, 2, 3, 4, 1, 11, 10 ,11 ,12 ,13,
| 3).foldLeft(List[List[Int]]()){(a,b)=>
| if(a.isEmpty) List(List(b))
| else if(a.last.last < b) a.dropRight(1):::List(a.last:+b)
| else a:::List(List(b))
|
}.filter(_.
On 12 June 2012 14:28, Jim - FooBar(); wrote:
> Of course, I Just noticed that type-hinting 'p' renders the precondition
> useless...an extra performance bonus!
Not really -- only primitive type hints actually prevent the function
from accepting a non-matching argument:
(defn foo [^java.util.Map
On 12 June 2012 22:00, Jim - FooBar(); wrote:
> On 12/06/12 19:41, Alan Malloy wrote:
>>
>> It's not just less convenient, but genuinely incorrect to use dot-
>> notation for protocol functions. Not every class that satisfies the
>> protocol will be implementing the interface directly, and so dot-
On 13 June 2012 06:34, Michał Marczyk wrote:
> Not really -- only primitive type hints actually prevent the function
> from accepting a non-matching argument:
Should have added a primitive hint example:
(defn foo [^long x] x)
(foo {})
; ClassCastException
M.
--
You received this message beca
Sean Corfield writes:
>> user> (map #(let [{x 0 y 1 :or {0 -1, 1 -2}} %1]
>> [x y])
>> [[] [10] [10 11]])
>> ([nil nil] [10 nil] [10 11])
>>
>> I had expected it to return ([-1 -2] [10 -2] [10 11]).
>
> It needs to be this:
>
> user=> (map #(let [{x 0 y 1 :or {x -1 y -2}} %]
Great!
On Tuesday, June 12, 2012 11:32:11 PM UTC+2, Jim foo.bar wrote:
>
> Nevermind...I found the namespace with these non-relational operators and
> the code works like a charm!!! I am so happy... :-)
>
> Jim
>
>
> On 12/06/12 22:18, Jim - FooBar(); wrote:
>
> Hi Marek,
>
> I did what you s
Jay Fields writes:
> right, I know it's possible to do what you guys are describing. What I
> meant to ask is, should :or be allowed in destructuring vectors? I
> can't see any reason for it not to be allowed.
Hm, yes, I could think of these semantics, i.e., fill missing indices
with the values
66 matches
Mail list logo