Re: Lazy Sequence Results in Stack Overflow

2015-09-28 Thread Yoshinori Kohyama
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

Re: A generalization of iterate

2015-09-28 Thread Yoshinori Kohyama
t 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 patient with yo

To refer an auto-gensymed symbol in an internal unquoted expression?

2013-11-27 Thread Yoshinori Kohyama
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 email to clojure@googlegroups.com Note

Re: To refer an auto-gensymed symbol in an internal unquoted expression?

2013-11-27 Thread Yoshinori Kohyama
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 patient

Re: To refer an auto-gensymed symbol in an internal unquoted expression?

2013-11-27 Thread Yoshinori Kohyama
] (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 subscribed to the Google Groups Clojure group. To post to this group

Re: How to generalize these functions

2013-10-03 Thread Yoshinori Kohyama
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 Note that posts from

How to generalize these functions

2013-10-01 Thread Yoshinori Kohyama
(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 subscribed

To read and write bytes via Socket

2013-08-28 Thread Yoshinori Kohyama
[]'. * 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 this message because you

Re: To read and write bytes via Socket

2013-08-28 Thread Yoshinori Kohyama
) . 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 moderated - please be patient

Re: To read and write bytes via Socket

2013-08-28 Thread Yoshinori Kohyama
[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.com Note that posts from new members

Can I refer all but specified symbols with 'ns' macro?

2013-08-01 Thread Yoshinori Kohyama
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.

Re: Can I refer all but specified symbols with 'ns' macro?

2013-08-01 Thread Yoshinori Kohyama
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

Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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?

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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?

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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.

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
, 2013 at 1:31 PM, Yoshinori Kohyama yyko...@gmail.comwrote: 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

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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

Re: Does this abstraction have any existing name?

2013-07-26 Thread Yoshinori Kohyama
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秒

Re: Sequential conditional transforms of an argument

2013-07-08 Thread Yoshinori Kohyama
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

Re: group-by replacement when an item has many groups?

2013-07-08 Thread Yoshinori Kohyama
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), *

Re: Interleaving

2013-06-27 Thread Yoshinori Kohyama
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

Re: alter a map in a vector (reference)

2013-06-11 Thread Yoshinori Kohyama
-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 clojure@googlegroups.com Note that posts

Re: How things are going about expansion, class creation and loading of procedures

2012-12-11 Thread Yoshinori Kohyama
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

How things are going about expansion, class creation and loading of procedures

2012-12-10 Thread Yoshinori Kohyama
is 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

Re: How to add an URL into the classpath?

2012-12-10 Thread Yoshinori Kohyama
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 members

Re: Proposal/request: Give clojure.core/conj a unary implementation

2012-12-10 Thread Yoshinori Kohyama
+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 #{1 2 3}

Re:

2012-07-31 Thread Yoshinori Kohyama
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 moderated - please

Re: How to add an URL into the classpath?

2012-07-30 Thread Yoshinori Kohyama
/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 dce.core (:import java.net.URL

Re: How to add an URL into the classpath?

2012-07-30 Thread Yoshinori Kohyama
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. To

Re:

2012-07-30 Thread Yoshinori Kohyama
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 subscribed

Re: How to add an URL into the classpath?

2012-07-29 Thread Yoshinori Kohyama
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

Re:

2012-07-29 Thread Yoshinori Kohyama
#(= % [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 Google Groups Clojure group. To post to this group, send email to clojure

Re: How to add an URL into the classpath?

2012-07-29 Thread Yoshinori Kohyama
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@googlegroups.com

How to add an URL into the classpath?

2012-07-27 Thread Yoshinori Kohyama
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 Kohyama -- You received this message because you

Re: so why it has to be so complicated / Longest Increasing Sub-Seq

2012-06-14 Thread Yoshinori Kohyama
%)) % %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 posts from new members are moderated - please

Re: How about 'nth' accepts maps?

2012-06-13 Thread Yoshinori Kohyama
))) 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 (apply vector (map (fn [[k v]] (assoc v :id k)) sm)) Regards, Yoshinori Kohyama -- You received this message

How about 'nth' accepts maps?

2012-06-12 Thread Yoshinori Kohyama
: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 opinions. Regards, Yoshinori Kohyama -- You received this message

Re: How about 'nth' accepts maps?

2012-06-12 Thread Yoshinori Kohyama
/clojure/core.clj#L2747 Note that the example above is done without a loop, I know, and I forced to use a loop for a demonstrative purpose. Regards, Yoshinori Kohyama -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: Why isn't there a fold-right?

2012-06-11 Thread Yoshinori Kohyama
. 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 received this message because you are subscribed to the Google Groups Clojure group

Re: Why isn't there a fold-right?

2012-06-11 Thread Yoshinori Kohyama
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, Yoshinori Kohyama -- You received this message because you

Re: Why isn't there a fold-right?

2012-06-11 Thread Yoshinori Kohyama
of 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 group. To post

Re: Why isn't there a fold-right?

2012-06-11 Thread Yoshinori Kohyama
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 patient with your

Re: Why isn't there a fold-right?

2012-06-11 Thread Yoshinori Kohyama
*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 to clojure@googlegroups.com Note that posts from new members

Re: Why isn't there a fold-right?

2012-06-10 Thread Yoshinori Kohyama
/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 is there any lazy solution? Regards, Yoshinori Kohyama -- You received this message because you are subscribed to the Google Groups Clojure group

Re: Why isn't there a fold-right?

2012-06-10 Thread Yoshinori Kohyama
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,

Re: Why isn't there a fold-right?

2012-06-10 Thread Yoshinori Kohyama
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 because you

Re: Why isn't there a fold-right?

2012-06-08 Thread Yoshinori Kohyama
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)