s o.k. that we can assume at least one argument.
Yoshinori Kohyama
--
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 patie
Hi, Charles and all.
Here is my definition of prime numbers:
https://gist.github.com/kohyama/8e599b2e765ad4256f32
HTH.
Yoshinori Kohyama
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@google
~d ~a)
a 3)
(clojure.core/fn [foo20] (clojure.core/drop 3 foo20))
user=> ((fn [d] (let [a (gensym "foo")] `(fn [~a] ~(if d `(drop ~d ~a)
a nil)
(clojure.core/fn [foo25] foo25)
Thank you.
Best Regards,
Yoshinori Kohyama
--
--
You received this message because you are subsc
Meikel,
I see! Thanks a lot.
Best regards,
Yoshinori Kohyama
--
--
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 pa
expression which I can use instead of `(drop ~d a#) and
`a# in the first expression in the example above.
Thank you in advance.
Regards,
Yoshinori Kohyama
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send em
Smart! That's just what I want to do.
Thanks, Leif and the author of Prismimatic.
Best Regards,
Yoshinori Kohyama
--
--
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
ncat
(keep (fn [[k v]] (g (conj kv k) v)) n))
(if-let [fna (apply f n args)]
[[kv fna]])))
[] m)))
https://gist.github.com/kohyama/6789280 (with examples as tests)
Regards,
Yoshinori Kohyama
--
--
You received this message because you are subscribe
.flush os)))
sent [0x00, 0x01, 0x7f, 0x80, 0xff] to my test server.
Thank you, Armando and all.
Regards,
Yoshinori Kohyama
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.
uf, int off, int len)
.
Does anyone have any information?
Thanks in advance.
Yoshinori Kohyama
--
--
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
requires 'char[]'.
* What is the valid char value to send a byte 0x80?
* How can I make the char value from 0x80 int?
* How are things about read.
* Does character encoding environment affect? (I use -Dfile.encoding=UTF-8)
Thank you in advance.
Yoshinori Kohyama
--
--
You received thi
Carlo,
Works fine. Thank you!
Y. Kohyama
--
--
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 your
first post.
To u
Hi group.
Assumed that I want to refer 'baz, 'qux and etc and don't want to refer
'quux of 'bar namespace within my 'foo namespace.
With 'ns' macro, I can require a namespace and refer all public symbols in
it.
(ns foo (:require [bar :refer :all]))
I can refer only some specific symbols.
Thanks Ben, for very useful informations!
2013年7月27日土曜日 13時31分41秒 UTC+9 Ben:
>
> if you want to use that fmap (or, I'd think, the fmaps provided by either
> morph or fluokitten) with uneven depths, you'd have to wrap them in a
> defrecord or deftype, I'd expect.
>
I see.
2013年7月27日土曜日 13時37分28
Thank you, Jason.
The 'map-leaves' does the same as my 'mapf' and simpler.
Its name and implementation is very sophisticated with other functions doing
similar but different things.
Thanks the information.
Regards,
Y.Kohyama
2013年7月27日土曜日 13時31分28秒 UTC+9 Jason Wolfe:
>
> This is 'map-leaves' in
er seen a name for that.
>>>> 2) not in core. I'm sure it's been written 50 times in various helper
>>>> libs.
>>>> 3) I'd probably write it like below, but I'm not convinced it's any
>>>> better.
>>>>
>>&g
Thank you, Dave.
Yes, I'm thinking of a nested map as a sort of tree.
Then, what I do may be called 'map-leaves', as you say.
Is there an existing function named like that?
Or did you say that just as 'an abstraction name'?
Y.Kohyama
2013年7月27日土曜日 10時02分17秒 UTC+9 Dave Sann:
>
> if you are think
Thanks, Jay.
Your reply helps me much.
I often think which is better,
(into {} (map (fn [[k v]] [k (f v)]) m))
and
(reduce (fn [a [k v]] (assoc a k (f v))) m m)
or
(reduce-kv (fn [a k v] (assoc a k (f v))) m m)
, where f is a function, m is a map.
Any body have any opinion?
Thanks.
Y. Kohy
Thank you Gary.
There's no reason why this need to be a macro.
It has rewritten as a function.
And I'd still like to hear any response about the same three questions.
(require '[clojure.test :refer (with-test is run-tests)])
(with-test
(defn mapf [f m & args]
((fn g [n]
(if (map?
Hello group.
I wrote a tiny macro to apply a function to values in lowest levels in a map
with arguments.
Three questions:
- Does this abstraction have any existing name?
- Is there any existing function/macro to do similar things?
- Would anyone improve this implementation?
(requir
Hi Colin,
One more solution, with example data in the process commented
*(let [f #(range 1 (inc %))*
* coll '(1 2 3)]*
* (->>*
**(for [*x coll*; x = 1, 2, 3
* y *(*f x*)]* *; y = 1 (where x = 1),
**; 1, 2(where x = 2),
*
Hi Laurent,
How about a macro like below?
(defmacro tt
([x] x)
([x ts tr & more] `(tt (if (~ts ~x) (~tr ~x) ~x) ~@more)))
To use this,
(tt x test1 transform1 test2 transform2 test3 transform3)
This doesn't work even number of arguments as you see.
HTH,
Y.Kohyama
--
--
You recei
One more solution.
user=> (mapcat (fn [[x y] z] [x y z]) (partition 2 '(:x1 :y1 :x2 :y2 :x3
:y3)) '(:z1 :z2 :z3))
(:x1 :y1 :z1 :x2 :y2 :z2 :x3 :y3 :z3)
Y. Kohyama
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
e-in (into {} (map #(vector (:id %) %) v))
[1 :emails "a...@mail.com"]
inc)
HTH,
with regards,
Yoshinori Kohyama
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to cloj
Mr. @athos0220 gave me a great help via twitter.
https://twitter.com/athos0220/status/278439357126418432 (in Japanese)
http://ideone.com/8mBm5N
https://gist.github.com/4255602
Now I can write macros without class files.
Thank you.
With regards,
Yoshinori Kohyama
--
You received this message
+1
2012年11月4日日曜日 7時27分24秒 UTC+9 CGAT:
>
> It would be nice if clojure.core/conj had a unary implementation
>
>([coll] coll)
>
> The motivating use case is when one is conjoining sequences of
> items to a collection all at once:
>
>(apply conj coll seqable)
>
> such as (apply conj #
Hi Vladimir and Alex,
Thank you for very useful informations.
With regards,
Yoshinori Kohyama
--
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 m
created for each procedure,
* which version of procedure is used and
* when an inline version of procedure is used, if the class file is loaded?
https://gist.github.com/4255602
Please teach me any information around these things.
Best regards,
Yoshinori Kohyama
--
You received this message because
ing a throwable object is a good alternative for me.
Thank you again.
Regards,
Yoshinori Kohyama
--
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 mod
Hi Nicolas,
The technique, using throw an Exception when succeeded in searching,
strikes me!
Not idiomatic but very practical.
It's like a break in a loop of imperatives.
I may use it somewhere.
Thank you.
Regards,
Yoshinori Kohyama
--
You received this message because you are subscrib
I forgot to show foo/core.clj
$ cat samples/src/foo/core.clj
(ns foo.core)
(defn -main [& args]
(loop []
(println "Foo: " (apply str (interpose " " args)))
(Thread/sleep 1000)
(recur)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
/currentThread)))
Details reported below.
Regards,
Yoshinori Kohyama
$ cat project.clj
(defproject dce "0.0.1"
:description "Dynamic Compling And Execution"
:dependencies [[org.clojure/clojure "1.3.0"]]
:main dce.core)
$ cat src/dce/core.clj
(ns dc
Hi Sierra,
Thank you for your kind and quick answers to my questions.
I see.
I'll read the page you referred.
Regards,
Yoshinori Kohyama
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@g
eed two or more pairs of 2s, do
(defn has222 [coll] (< 1 (count (filter #(= % [2 2]) (partition 2 1
coll)
(has222 [1 2 3 4]) -> false
(has222 [1 2 2 4]) -> false
(has222 [1 2 2 2]) -> true
Regards,
Yoshinori Kohyama
--
You received this message because you are subscribed to the
Hello programmers,
Hi, Sierra. Thank you replying.
O.K. I can not always contol the classloader of the whole JVM.
Then, how can I get the dynamic classloader for my current code/thread?
Or can't I?
Regards,
Yoshinori Kohyama
--
You received this message because you are subscribed t
he loader gotten with .getContextClassLoader is an instance
of clojure.lang.DynamicClassLoader,
the latter is an sun.misc.Launcher$AppClassLoader.
How can I get an clojure.lang.DynamicClassLoader?
Or am I wrong with something?
Please teach me any information about this.
Regards,
Yoshinori Kohyam
duce #(if (< (count %2) (count %)) % %2) [])
))
https://gist.github.com/2928234
Regards,
Yoshinori Kohyama
--
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 p
f x
(recur xs (conj acc (assoc v :id k)))
acc))
[{:name "Alice", :id 0} {:name "Bob", :id 1} {:name "Charlie", :id 2}]
I'm sorry for all the fuss.
By the by, to get the same result as the example above, what to do is
(appl
ing
'seq', 'first', 'next', 'loop' and 'recur' like 'nthnext' or 'my-nth' in
the first post.
https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L2747
Note that the example above is done without a loop, I
returned
[[1 :a] [2 :b] [3 :c] {4 :d 5 :e} {1 :a 2 :b 3 :c 4 :d 5 :e}]
.
Or isn't it good that you can write operations for a map like
(loop [[[k v :as x] & xs] m acc '()]
(if x
(recur xs (cons acc (some-operation-for k v)))
acc))
?
Please let me hear opi
:*
https://gist.github.com/2896939
3) Related function *unfold*: https://gist.github.com/2901487
They no longer need a large heap.
Regards,
Yoshinori Kohyama
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
very faster.
Still need little bit of heap.
Regards,
Yoshinori Kohyama
--
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 pa
f the function
instead of sequencial tests of multiple versions of a function in one
runtime.
Or do sequencial tests of multiple versions of a function in the reverse
order.
Regards,
Yoshinori Kohyama
--
You received this message because you are subscribed to the Google
Groups "Clojure"
Hi Meikel,
Thank you for pointing it out that 'comp' calls 'reverse' internally.
I've been calling 'reverse' twice.
Appreciate you so much.
I'll try 'comp'ing the accumulated functions manually without 'reverse'.
Regards,
Yosh
of partial functions is expensive as you say.
May it be that 'conj'ing an element at the last of a collection still takes
much cost than 'cons'ing
an element at the head of it and reversing?
I'll keep thinking and trying.
Regards,
Yoshinori Kohyama
--
You rec
Hi all.
Sorry for mere my continued report.
Instead of reversing operands, I tried accumulating operators and reversing
and applying it when stopping.
https://gist.github.com/2896939
It doesn't consume stack. (but heap...)
Regards,
Yoshinori Kohyama
--
You received this message becaus
Hi O. Masanori and all,
Thank you so much for your kindly explanation.
Sure that 'fold-right' itself is strict as you say.
But I think that various right-folded-type loops, which can be stopped
middle of a list, can be lazy.
The continuation, which should be calculated in the later steps, shoul
27;reduce1' and commented "Not lazy".
https://github.com/clojure/clojure/blob/d0c380d9809fd242bec688c7134e900f0bbedcac/src/clj/clojure/core.clj#L865
The source of 'reduce1' says it uses 'chunk-seq?', '.reduce', 'chunk-first'
and 'chunk-next'.
What are these?
And i
Hello caffe and Yang Dong.
Here is my fold-right.
(defn fold-right [f s coll]
((reduce (fn [acc x] #(acc (f x %))) identity coll) s))
; (fold-right - 1 '(3 1 4))
; -> ((fn [y3]
; ((fn [y2]
; ((fn [y1] (identity (- 3 y1)))
;(- 1 y2)))
; (- 4 y3)))
; 1)
48 matches
Mail list logo