(def graph
{"a" {:dependencies ["b" "d"]}
"b" {:dependencies ["c" "e"]}
"c" {:dependencies ["d" "e"]}
"d" {:dependencies []}
"e" {:dependencies []}})
(defn resolve-dep
[graph name]
(let [resolved (atom [])
resolved-set (atom #{})
f (fn f [name]
(doseq
I often need to do this when writing hiccup helper functions:
(defn my-widget
[& args]
(let [attrs(if (map? (first args)) (first args) {})
contents (if (map? (first args)) (next args) args)]
...
I found this post, but considering that it is 4 years old, is there
any new libra
I sometimes need to inspect or modify the map in the function, but
defelem only merges the map.
On Jun 4, 2:30 am, gaz jones wrote:
> You could look at the impl:
>
> https://github.com/weavejester/hiccup/blob/master/src/hiccup/def.clj
>
>
>
>
>
>
>
> On Mon, Jun
The same reason that hiccup tag vector is taking optional attribute
map.
It's more readable.
(my-widget {:id "id1"} "hello" "world")
vs.
(my-widget {:attr {:id "id1"} :contents '("hello" "world")})
On Jun 4, 2:38 am, &qu
> (defn my-widget
> ([attrs contents] (apply widget-creator attrs contents)) ;;I have no idea
> what widget-creator might be
> ([contents] (my-widget {} contents))
> ([] (my-widget {} []))
contents of one arity version can be a map. so the code should be
(defn my-widget
([attrs c
map?) (v vector?) (s String) n]
On Jun 4, 2:22 am, Alice wrote:
> I often need to do this when writing hiccup helper functions:
>
> (defn my-widget
> [& args]
> (let [attrs (if (map? (first args)) (first args) {})
> contents (if (map? (first args)) (next args
b] [2]]
[a b])
;= [{:p "default"} 2]
(let2 [[a (b map?) (c String) d] ["abc" "def" "ghi"]]
[a b c d])
;= ["abc" nil "def" "ghi"]
What do you think? Considering that everyone is writing their own
macros or helper functions, i
Wouldn't ! for a take more natural than the current one?
When I read code like (- 1 2), I tranform it into (1 - 2) in my head,
likewise when I see (>! c "hi"), I read it as (c >! "hi"), which doesn't
look right.
--
--
You received this message because you are subscribed to the Google
Groups "C
user=> (go
(try
(go (throw (Exception.)))
(catch Exception ex
(println "catched"
IllegalArgumentException contains? not supported on type:
clojure.lang.PersistentList clojure.lang.RT.contains (RT.java:724)
Why am I getting this error?
--
--
Yo
https://github.com/clojure/core.async/blob/master/examples/ex-async.clj
https://github.com/clojure/core.async/blob/master/examples/ex-go.clj
One uses future, and the other uses go. The code runs query twice for each
search type, and takes only one, whichever comes first, from the channel,
so I'm
(defonce ^ExecutorService db-thread-pool (Executors/newFixedThreadPool 8))
(defn db-thread-call
[f]
(let [c (chan 1)]
(.execute db-thread-pool
(fn []
(let [ret (try
(f)
(catch Throwable t
It would be nice to have a function throw>! that puts an exception into the
channel and throws it when taken, so that I can write
(let [c (chan)]
(go (throw>! c (Exception.)))
(go (try
(prn (! c (Exception.)))
(go (try
(let [res (http://groups.google.com/group/clojure?hl=en
It doesn't produce a compile time error but I think it's not the correct
code because the transaction can be committed while insert-async! is still
executing.
On Thursday, August 1, 2013 2:46:29 AM UTC+9, Sean Corfield wrote:
>
> On Wed, Jul 31, 2013 at 10:29 AM, Alice >
I have an async http handler and I don't want it to consume a thread.
On Thursday, August 1, 2013 3:16:52 AM UTC+9, tbc++ wrote:
>
> Why not use
> Timothy
>
>
> On Wed, Jul 31, 2013 at 11:58 AM, Alice >wrote:
>
>> It doesn't produce a compile time error b
>
> Anyways, that's the way I'm thinking these days.
>
> Timothy
>
>
>
>
> On Wed, Jul 31, 2013 at 12:24 PM, Alice >wrote:
>
>> I have an async http handler and I don't want it to consume a thread.
>>
>> On Thursday, August 1, 2013 3:
tern: create processors using threads, then send data to
> those processors via a shared channel, passing in a response channel.
>
> Anyways, that's the way I'm thinking these days.
>
> Timothy
>
>
>
>
> On Wed, Jul 31, 2013 at 12:24 PM, Alice >wrote
thods (and may more) are supported by core.async...it simply
> doesn't care how you handle exceptions, but it is up to you to specify how
> they are handled.
>
> Timothy
>
>
> On Wed, Jul 31, 2013 at 11:49 AM, Alice >wrote:
>
>> It would be nice to have a funct
(defmacro foo
[c]
`(!! c :hi))
I thought this would not work because foo is expanded after go is expanded,
so http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop r
I didn't know that macros can do that! Thanks for the detailed answer.
On Monday, August 5, 2013 8:00:16 PM UTC+9, Tassilo Horn wrote:
>
> Alice > writes:
>
> > (defmacro foo
> > [c]
> > `( >
> > (let [c (chan)]
> > (go (prn (foo c)))
I've used those as a debugging tool, and never thought about using it
inside a macro.
On Monday, August 5, 2013 8:52:56 PM UTC+9, Tassilo Horn wrote:
>
> Alice > writes:
>
> > I didn't know that macros can do that!
>
> Then you might want to have a look a
e way you want, you need to do one of the following
>
> `(~'>! c 42)
>
> or
>
> `(clojure.core.async/>! c 42)
>
> Or, if you've done the following
>
> (ns user
> (require [clojure.core.async :as async))
>
> Then you can do this:
>
> `(as
r/>! to core.async? It has no clue that
> you want that to be a put and not something else. So yes, either async/>!
> or a fully qualified symbol is what you want here.
>
> Timothy Baldridge
>
>
> On Mon, Aug 5, 2013 at 7:40 AM, Alice >wrote:
>
>> I
It would be convenient if I can specify the default entities and
identifiers functions in a database spec. I usually want those mappings to
be applied all the time.
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send emai
Yes. It's described at
http://clojure-doc.org/articles/ecosystem/java_jdbc/name_mapping.html.
On Monday, August 26, 2013 10:13:22 PM UTC+9, Shantanu Kumar wrote:
>
> Hi Alice,
>
> Do you mean default `values` for entity columns for INSERT statements? And
> by `identifiers fu
of the
> DSL, in general. This request has come up in the past and it just
> isn't practical since the db-spec is completely independent of the
> DSL.
>
> On Mon, Aug 26, 2013 at 6:06 AM, Alice >
> wrote:
> > It would be convenient if I can specify t
Unlike explained in
http://blog.klipse.tech/clojure/2016/11/24/stringify-clojure.html (str
"Hello\nWorld") just prints "Hello\nWorld"(Surrounding quotes are preserved and
new lines are not interpreted). String.toString() just returns the string
itself, so I have no idea why it should be the way
user=> (def obj (Object.))
#'user/obj
user=> (defmacro mac1 [& body] `(locking ~obj ~@body))
#'user/mac1
user=> (mac1 nil)
CompilerException java.lang.RuntimeException: Can't embed object in code,
maybe print-dup not defined: java.lang.Object@2a747a37,
compiling:(NO_SOURCE_PATH:1:1)
Why am I ge
I get a reflection warning "reference to field printstacktrace can't be
resolved" from the following code:
(defn foo
[]
(go-loop []
(http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscrib
[org.clojure/clojure "1.7.0"]
[org.clojure/core.async "0.2.374"]
On Monday, November 16, 2015 at 8:28:27 PM UTC+9, Alex Miller wrote:
>
> Which version of core.async?
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email t
Sorry, I was having some copy & paste mistake, but I'm seeing the same
warning with .printStackTrace.
On Monday, November 16, 2015 at 9:25:06 PM UTC+9, Herwig Hochleitner wrote:
>
> The method is called .printStackTrace:
> http://docs.oracle.com/javase/7/docs/api/java/lang/Throwable.html#printSt
Which one is preferred?
.length needs to be type hinted, so more verbose.
The performance penalty of count is negligible in most cases.
I think including len in clojure.string would be a good idea because it's
used so often.
--
--
You received this message because you are subscribed to the Go
tion.
On Wednesday, October 30, 2013 7:50:04 PM UTC+9, Baishampayan Ghose wrote:
>
> What'd clojure.string/len do any differently than clojure.core/count?
> count already provides does the fastest possible thing for strings.
> ~BG
>
> On Wed, Oct 30, 2013 at 4:14 PM, Al
I found it inconvenient that the printed message of the thrown
ExceptionInfo object doesn't include the attached map.
user=> (throw (ex-info "foo" {:type "my error"}))
ExceptionInfo foo clojure.core/ex-info (core.clj:4327)
When testing the function that throws ExceptionInfo, I have to wrap it w
I agree with Colin and had a similar experience.
Even if you say it's completely optional, people will first try it because
it's already included. I think honeysql is good and also not any harder to
use than the included DSL. It's concept is very simple and clear. Actually,
your DSL is magical
Why doesn't (.length (int-array 5)) work?
Why should I use alength or count instead?
--
--
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 - ple
On http://clojure.org/lazier,
Changed: (rest aseq) - returns a logical collection (Sequence) of
the remaining items, not (necessarily) a seq
rest simply calls RT.more and here's the code of RT.more:
static public ISeq more(Object x){
if(x instanceof ISeq)
return ((ISeq) x).more();
1)
public class Foo {
public static String bar(byte b) {
return "byte";
}
}
user=> (Foo/bar 1)
"byte"
public class Foo {
public static String bar(byte b) {
return "byte";
}
public static String bar(Thread thread) {
return "thread";
}
}
user=> (Foo/bar 1)
IllegalArgument
The problem is that the current behavior is not consistent with what
you describe. Sometimes it fails, but sometimes it works when it
should fail.
And there's no documentation or guidelines about the current behavior
at all, so it's all very confusing.
My opinion is that interop is essentially ug
(defn foo [^long l cb] (cb l))
(time
(dotimes [n 100]
(foo n (fn [l] nil
(time
(dotimes [n 100]
(foo n (fn [^long l] nil
"Elapsed time: 7.861 msecs"
"Elapsed time: 11.770973 msecs"
Why is the latter slower?
--
--
You received this message because you are subscrib
I tested several times, but the latter is always slower.
On Apr 25, 12:38 am, Jim wrote:
> On 24/04/13 16:35, Alice wrote:
>
>
>
>
>
>
>
> > (defn foo [^long l cb] (cb l))
>
> > (time
> > (dotimes [n 100]
> > (foo n (fn
compiler however.
> It could be an edge case not optimized yet. On the other hand if the argument
> is not
> used at all, why bother with such an edge case ?
>
> Luc P.
>
>
>
>
>
>
>
>
>
> > On 24/04/13 16:35, Alice wrote:
> > > (defn foo [^long
, type-hinting to primitive types doesn't do you any good in the
> presence of higher-order functions like `map`.
>
> -S
>
>
>
>
>
>
>
> On Wednesday, April 24, 2013 11:35:11 AM UTC-4, Alice wrote:
>
> > (defn foo [^long l cb] (cb l))
>
> > (tim
invokePrim ^IFn$LO f n) using several checks at
> compile time.
>
> Am Mittwoch, 24. April 2013 19:15:49 UTC+2 schrieb Alice:
>
>
>
>
>
>
>
>
>
> > So, is there a way to type hint on cb that it has a function accepting
> > a long argument?
>
> >
The reason foo2 is faster is that foo1 is passing a primitive long
value to cb, which caused boxing. Without that, the performance seems
to be exactly the same, which it should be!
On Apr 25, 6:50 pm, Alice wrote:
> Wow! That's awesome. It's even faster! Thanks.
>
> (defn foo1
I create many small methods in java without worrying about the
performance since it's usually the target of inline optimization. For
example,
public class Foo {
public static long inc(long l) {
return ++l;
}
public static long f1() {
long l = 0;
for (int i=0; i < 10; i++
ilt some tools to avoid the various potential pitfalls.
>
>
>
>
>
>
>
> On Thu, Apr 25, 2013 at 9:19 AM, Alice wrote:
> > I create many small methods in java without worrying about the
> > performance since it's usually the target of inline optimization.
/defn special forms is called.
This indirection is not amenable to HotSpot optimizations."
http://blog.fogus.me/2011/10/14/why-clojure-doesnt-need-invokedynamic-but-it-might-be-nice/
On Apr 25, 10:19 pm, Alice wrote:
> I create many small methods in java without worrying about the
> perfor
Care to elaborate which part is out of date?
On Apr 26, 1:48 am, David Nolen wrote:
> Which is out of date.
>
>
>
>
>
>
>
> On Thu, Apr 25, 2013 at 12:47 PM, Alice wrote:
> > Found this blog post written by fogus:
>
> > "To provide this leve
I'm reading Clojure Programming from O'Reilly.
(defn a [b] (+ 5 b))
;= #'user/a
(def b (partial a 5))
;= #'user/b
(b)
;= 10
(defn a [b] (+ 10 b))
;= #'user/a
(b)
;= 10
Redefining a has no effect. But,
(defn foo [] 1)
;= #'user/foo
(defn bar [] (foo))
;= #'user/bar
(bar)
;= 1
(defn foo [] 2)
;= #
Hi,
I'm using emacs with inferior-lisp setup to use lein repl. Everything
works fine, but when I start the repl, I see two java.exe processes on
my windows task manager.
Is this normal behavior? Why two java processes not one are needed?
--
You received this message because you are subscribed t
c:\hello.clj:
(clojure.main/repl)
C:\>java -jar clojure-1.4.0.jar hello.clj
user=>
And then the file becomes read-only.
I'm launching repl myself to avoid threading issue in my wpf project.
(https://gist.github.com/3062194)
--
You received this message because you are subscribed to the Goog
51 matches
Mail list logo