[?] alter-var-root and *out*

2021-09-01 Thread Philos Kim
I can change my dynamic var with alter-var-root like this.

(def ^:dynamic *x* "abc")
(alter-var-root #'*x* (constantly "xyz"))
*x*
; => "xyz"


However, I cannot change *out* with alter-var-root.

(alter-var-root #'*out* (constantly "xyz"))
*out*
; => #object[java.io.PrintWriter 0x6957ec80 "java.io.PrintWriter@6957ec80"]


I expected the result to be "xyz" but the result of *out* doe not change at 
all

Can anyone explain to me why?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/23d13e9b-6eb8-4a39-b00d-8fead541e18en%40googlegroups.com.


Debux 0.8.0 is out.

2021-08-09 Thread Philos Kim
Debux(https://clojars.org/philoskim/debux) is a trace-based debugging 
library for Clojure and ClojureScript.

* new feature: dbgt and clogt macros added for debugging transducers.

https://github.com/philoskim/debux#dbgt

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/075c0034-36e0-4891-b9ad-b9d63eeaaa81n%40googlegroups.com.


How to print the intermediate values in a transient vector?

2020-06-25 Thread Philos Kim
How can I print the *intermediate values* in a transient vector?

I tried this but the printed result is not what I want to see.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(println v)))
;; printed v
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]

So I retried like this but failed with an exception.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(persistent! v)
(println v)))
IllegalAccessError Transient used after persistent! call  
clojure.lang.PersistentVector$TransientVector.ensureEditable 
(PersistentVector.java:548)

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/872b0aa3-033b-4ea2-b19b-02e9ca4875b2o%40googlegroups.com.


How to print the intermediate values in a transient vector?

2020-06-25 Thread Philos Kim
How can I print the intermediate values in a transient vector?

I tried this but the printed result is like this and it is not what I want 
to see.


(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(println v)))
;; printed v
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]
#object[clojure.lang.PersistentVector$TransientVector 0x162d8132 
clojure.lang.PersistentVector$TransientVector@162d8132]

So I retried like this but failed with an exception.

(let [v (transient [])]
  (dotimes [n 3]
(conj! v n)
(persistent! v)
(println v)))
IllegalAccessError Transient used after persistent! call  
clojure.lang.PersistentVector$TransientVector.ensureEditable 
(PersistentVector.java:548)

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/clojure/7a4ca9be-40a8-4f56-b9dc-0622855ae2e9o%40googlegroups.com.


Re: [?] Spec error: please tell me the reason.

2019-10-30 Thread Philos Kim
Thanks for your answer!

I corrected the code like the following according to your advice.

(s/fdef transform-fontspecs
  :args (s/cat :fontspecs ::fontspecs))

However, the same error occurs again.

2019년 10월 31일 목요일 오전 11시 44분 46초 UTC+9, Philos Kim 님의 말:
>
> I don't know why the following spec error occurred.
>
> Could anyone tell me why?
>
> (ns spec-test 
>(:require [clojure.spec.alpha :as s]
>  [clojure.spec.test.alpha :as stest]))
>
> ;;; spec definitions
>
> (s/def :msds.fontspec/tag #{:fontspec})
>
> (s/def ::id string?)
> (s/def ::size int?)
> (s/def ::family string?)
> (s/def ::color string?)
>
> (s/def :msds.fontspec/attrs 
>   (s/keys :req-un [::id ::size ::family ::color]))
>
> (s/def :msds.fontspec/content (s/cat))
>
> (s/def ::fontspec
>   (s/keys :req-un [:msds.fontspec/tag :msds.fontspec/attrs 
> :msds.fontspec/content]))
>
> (s/def ::fontspecs (s/* ::fontspec))
>
>
> ;;; spec application
>
> (defn transform-fontspecs
>   "fontspecs를 사용하기 편리한 형태로 변환한다."
>   [fontspecs]
>   (->> fontspecs
>(map (fn [{:keys [attrs] :as fontspec}]
>   [(get attrs :id) (dissoc attrs :id)] ))
>(into {}) ))
>
> (s/fdef transform-fontspecs
>   :args ::fontspecs)
>
> (stest/instrument `transform-fontspecs)
>
>
> ;;; test code
>
> (def test-sample
>   '({:tag :fontspec,
>  :attrs {:id "283f1EV", :size 21, :family "c2S6", :color ""},
>  :content ()}
> {:tag :fontspec,
>  :attrs
>  {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color "bhV3PsVh"},
>  :content ()}
> {:tag :fontspec,
>  :attrs {:id "uA2i", :size -5, :family "HHGoD", :color "J47ZX935"},
>  :content ()}))
>
> (transform-fontspecs test-sample)
> 2. Unhandled clojure.lang.Compiler$CompilerException
>Error compiling src/spec_test.clj at (55:1)
>#:clojure.error{:phase :compile-syntax-check,
>:line 55,
>:column 1,
>:source "/home/philos/work/metapdf/src/spec_test.clj"}
>  Compiler.java: 7648  clojure.lang.Compiler/load
>   REPL:1  metapdf.core/eval19243
>   REPL:1  metapdf.core/eval19243
>  Compiler.java: 7177  clojure.lang.Compiler/eval
>  Compiler.java: 7132  clojure.lang.Compiler/eval
>   core.clj: 3214  clojure.core/eval
>   core.clj: 3210  clojure.core/eval
>   main.clj:  437  clojure.main/repl/read-eval-print/fn
>   main.clj:  437  clojure.main/repl/read-eval-print
>   main.clj:  458  clojure.main/repl/fn
>   main.clj:  458  clojure.main/repl
>   main.clj:  368  clojure.main/repl
>RestFn.java: 1523  clojure.lang.RestFn/invoke
> interruptible_eval.clj:   79  
> nrepl.middleware.interruptible-eval/evaluate
> interruptible_eval.clj:   55  
> nrepl.middleware.interruptible-eval/evaluate
> interruptible_eval.clj:  142  
> nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
>   AFn.java:   22  clojure.lang.AFn/run
>session.clj:  171  
> nrepl.middleware.session/session-exec/main-loop/fn
>session.clj:  170  
> nrepl.middleware.session/session-exec/main-loop
>   AFn.java:   22  clojure.lang.AFn/run
>Thread.java:  748  java.lang.Thread/run
>
> 1. Caused by clojure.lang.ExceptionInfo
>Spec assertion failed.
>
>  Spec: #object[clojure.spec.alpha$regex_spec_impl$reify__2509 
> 0x3660c4ee "clojure.spec.alpha$regex_spec_impl$reify__2509@3660c4ee"]
> Value: (({:tag :fontspec,
>   :attrs {:id "283f1EV", :size 21, :family "c2S6", :color 
> ""},
>   :content ()}
>  {:tag :fontspec,
>   :attrs
>   {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color 
> "bhV3PsVh"},
>   :content ()}
>  {:tag :fontspec,
>   :attrs {:id "uA2i", :size -5, :family "HHGoD", :color 
> "J47ZX935"},
>   :content ()}))
>
>  Problems: 
>
> val: ({:tag :fontspec,
>:attrs {:id "283f1EV", :size 21, :family "c2S6", :color 
> ""},
>:content ()}
>   {:tag :fontspec,
>:attrs
&

[?] Spec error: please tell me the reason.

2019-10-30 Thread Philos Kim
I don't know why the following spec error occurred.

Could anyone tell me why?

(ns spec-test 
   (:require [clojure.spec.alpha :as s]
 [clojure.spec.test.alpha :as stest]))

;;; spec definitions

(s/def :msds.fontspec/tag #{:fontspec})

(s/def ::id string?)
(s/def ::size int?)
(s/def ::family string?)
(s/def ::color string?)

(s/def :msds.fontspec/attrs 
  (s/keys :req-un [::id ::size ::family ::color]))

(s/def :msds.fontspec/content (s/cat))

(s/def ::fontspec
  (s/keys :req-un [:msds.fontspec/tag :msds.fontspec/attrs 
:msds.fontspec/content]))

(s/def ::fontspecs (s/* ::fontspec))


;;; spec application

(defn transform-fontspecs
  "fontspecs를 사용하기 편리한 형태로 변환한다."
  [fontspecs]
  (->> fontspecs
   (map (fn [{:keys [attrs] :as fontspec}]
  [(get attrs :id) (dissoc attrs :id)] ))
   (into {}) ))

(s/fdef transform-fontspecs
  :args ::fontspecs)

(stest/instrument `transform-fontspecs)


;;; test code

(def test-sample
  '({:tag :fontspec,
 :attrs {:id "283f1EV", :size 21, :family "c2S6", :color ""},
 :content ()}
{:tag :fontspec,
 :attrs
 {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color "bhV3PsVh"},
 :content ()}
{:tag :fontspec,
 :attrs {:id "uA2i", :size -5, :family "HHGoD", :color "J47ZX935"},
 :content ()}))

(transform-fontspecs test-sample)
2. Unhandled clojure.lang.Compiler$CompilerException
   Error compiling src/spec_test.clj at (55:1)
   #:clojure.error{:phase :compile-syntax-check,
   :line 55,
   :column 1,
   :source "/home/philos/work/metapdf/src/spec_test.clj"}
 Compiler.java: 7648  clojure.lang.Compiler/load
  REPL:1  metapdf.core/eval19243
  REPL:1  metapdf.core/eval19243
 Compiler.java: 7177  clojure.lang.Compiler/eval
 Compiler.java: 7132  clojure.lang.Compiler/eval
  core.clj: 3214  clojure.core/eval
  core.clj: 3210  clojure.core/eval
  main.clj:  437  clojure.main/repl/read-eval-print/fn
  main.clj:  437  clojure.main/repl/read-eval-print
  main.clj:  458  clojure.main/repl/fn
  main.clj:  458  clojure.main/repl
  main.clj:  368  clojure.main/repl
   RestFn.java: 1523  clojure.lang.RestFn/invoke
interruptible_eval.clj:   79  
nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:   55  
nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj:  142  
nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
  AFn.java:   22  clojure.lang.AFn/run
   session.clj:  171  
nrepl.middleware.session/session-exec/main-loop/fn
   session.clj:  170  
nrepl.middleware.session/session-exec/main-loop
  AFn.java:   22  clojure.lang.AFn/run
   Thread.java:  748  java.lang.Thread/run

1. Caused by clojure.lang.ExceptionInfo
   Spec assertion failed.

 Spec: #object[clojure.spec.alpha$regex_spec_impl$reify__2509 
0x3660c4ee "clojure.spec.alpha$regex_spec_impl$reify__2509@3660c4ee"]
Value: (({:tag :fontspec,
  :attrs {:id "283f1EV", :size 21, :family "c2S6", :color 
""},
  :content ()}
 {:tag :fontspec,
  :attrs
  {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color 
"bhV3PsVh"},
  :content ()}
 {:tag :fontspec,
  :attrs {:id "uA2i", :size -5, :family "HHGoD", :color 
"J47ZX935"},
  :content ()}))

 Problems: 

val: ({:tag :fontspec,
   :attrs {:id "283f1EV", :size 21, :family "c2S6", :color 
""},
   :content ()}
  {:tag :fontspec,
   :attrs
   {:id "BzYMt4eEm", :size -5, :family "q0xhOE3", :color 
"bhV3PsVh"},
   :content ()}
  {:tag :fontspec,
   :attrs {:id "uA2i", :size -5, :family "HHGoD", :color 
"J47ZX935"},
   :content ()})
 in: [0]
 failed: map?
   spec: :spec-test/fontspec

 alpha.clj:  132  
clojure.spec.test.alpha/spec-checking-fn/conform!
 alpha.clj:  140  
clojure.spec.test.alpha/spec-checking-fn/fn
   RestFn.java:  408  clojure.lang.RestFn/invoke
 spec_test.clj:   55  spec-test/eval19293
 spec_test.clj:   55  spec-test/eval19293
 Compiler.java: 7177  clojure.lang.Compiler/eval
 Compiler.java: 7636  clojure.lang.Compiler/load
  REPL:1  metapdf.core/eval19243
  REPL:1  metapdf.core/eval19243
 Compiler.java: 7177  clojure.lang.Compiler/eval
 Compiler.java: 7132  clojure.lang.Compiler/eval
  core.clj: 3214  clojure.core/eval
  

Re: [ANN] debux 0.5.0 is out

2018-09-10 Thread Philos Kim
The problem is solved in the newer 0.5.1 version of debux.

2018년 9월 9일 일요일 오후 3시 49분 59초 UTC+9, Mike 님의 말:
>
> Hello.
>
> I can't run debux on JVM 10. Issue is created 
> https://github.com/philoskim/debux/issues/11
>
> Mike.
>
> суббота, 8 сентября 2018 г., 19:56:14 UTC+3 пользователь Philos Kim 
> написал:
>>
>> Debux is a trace-based debugging library for Clojure and ClojureScript.
>>
>> https://github.com/philoskim/debux
>>
>> * Major improvement of version 0.5.0
>>
>>  - Multiple use of dbgn and dbg
>>   
>>  
>> https://github.com/philoskim/debux/blob/master/README.adoc#multiple-code-dbgn-code-and-code-dbg-code
>>
>>

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux 0.5.0 is out

2018-09-08 Thread Philos Kim
Debux is a trace-based debugging library for Clojure and ClojureScript.

https://github.com/philoskim/debux

* Major improvement of version 0.5.0

 - Multiple use of dbgn and dbg
  
 
https://github.com/philoskim/debux/blob/master/README.adoc#multiple-code-dbgn-code-and-code-dbg-code

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] The Reasoned Schemer vs. Core.logic

2018-08-24 Thread Philos Kim
I am studying *The Reasoned Schemer, 2nd ed.* and translating its source 
code into Clojure.

https://github.com/philoskim/reasoned-schemer-for-clojure

In the middle of studying the problem #98 of Chapter 3, I encountered an 
unexpected result like this.

https://github.com/philoskim/reasoned-schemer-for-clojure/blob/master/src/rs/ch3.clj#L498
  

in 3.100 the expected result is (fagioli e pasta).

So I debugged the code like this by using my debux 
 library. The dbg macro here just 
prints its executed result without interrupting the code execution.

(use 'debux.core)

(defn memberrevo [x l]
  (conde
[(dbg (emptyo l)) u#]
[s# (fresh [d]
  (dbg (resto l d))
  (dbg (memberrevo x d)))]
[s# (dbg (eq-caro l x))]))

(run* [x]
  (memberrevo x '(pasta e fagioli)))


Suprisingly, the execution order in printed results is not what I expected.


dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]


What I expected is as follows.


dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]
..


Because the code 

[s# (fresh [d]
  (resto l d)
  (memberrevo x d))]

precedes

[s# (eq-caro l x)]


I cannot understand this unexpected result at all. 

Could anyone explain to me why this happens?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] The Reasoned Schemer vs. core.logic

2018-08-24 Thread Philos Kim
I am studying *The Reasoned Schemer, 2nd ed.* and translating its source 
code into Clojure.

https://github.com/philoskim/reasoned-schemer-for-clojure

In the middle of studying the problem #98 of Chapter 3, I encountered an 
unexpected result like this.

https://github.com/philoskim/reasoned-schemer-for-clojure/blob/master/src/rs/ch3.clj#L498
  

in 3.100 the expected result is (fagioli e pasta).

So I debugged the code like this by using my *debux (*
https://github.com/philoskim/debux) library. The dbg macro here just prints 
its executed result without interrupting the code execution.

(use 'debux.core)

(defn memberrevo [x l]
  (conde
[(dbg (emptyo l)) u#]
[s# (fresh [d]
  (dbg (resto l d))
  (dbg (memberrevo x d)))]
[s# (dbg (eq-caro l x))]))

(run* [x]
  (memberrevo x '(pasta e fagioli)))


Suprisingly, the execution order of the printed result is not what I 
expected.


dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]


What I expected was as follows.


dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]

dbg: (emptyo l) =>
|   #function[clojure.core.logic/==/fn--15821]

dbg: (resto l d) =>
|   #function[clojure.core.logic/resto/fn--16152]

dbg: (memberrevo x d) =>
|   #function[rs.ch3/memberrevo/fn--21091]

dbg: (eq-caro l x) =>
|   #function[clojure.core.logic/firsto/fn--16147]
..


Because the code 

[s# (fresh [d]
  (resto l d)
  (memberrevo x d))]

precedes

[s# (eq-caro l x)]


I cannot understand the unexpected result at all.

Could anyone explain to me why this happens?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[TIP] How to alias the ClojureScript namespaces in macros

2018-07-09 Thread Philos Kim
Refer to https://groups.google.com/forum/#!topic/clojurescript/oP4qFdPRm2Q
 or https://gist.github.com/philoskim/496a01dc8d71b83c678c866874310871

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] How to alias the ClojureScript namespaces in macros

2018-07-09 Thread Philos Kim
Refer to https://groups.google.com/forum/#!topic/clojurescript/oP4qFdPRm2Q 
or https://gist.github.com/philoskim/496a01dc8d71b83c678c866874310871

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: When will the async/await feature in ES8 be introduced in ClojureScript?

2018-05-24 Thread Philos Kim
Refer to https://groups.google.com/forum/#!topic/clojurescript/scUMhU-ctEM 
for discussions.

2018년 5월 24일 목요일 오후 1시 19분 41초 UTC+9, Philos Kim 님의 말:
>
> I wonder when the async/await feature in ES8 will be introduced in 
> ClojureScript.
>
> Of course, I know there is core.async in ClojureScript but I hope that the 
> async/await feature in ES8 will be supported in ClojureScript as soon as 
> possible.
>
> Does anyone know when it will be supported?
>   
>

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


When will the async/await feature in ES8 be introduced in ClojureScript?

2018-05-23 Thread Philos Kim
I wonder when the async/await feature in ES8 will be introduced in 
ClojureScript.

Of course, I know there is core.async in ClojureScript but I hope that the 
async/await feature in ES8 will be supported in ClojureScript as soon as 
possible.

Does anyone know when it will be supported?
  

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[TIP] How to get *ns* string in ClojureScript

2018-04-09 Thread Philos Kim
https://gist.github.com/philoskim/19bafdac0d9d5610408157e528c053d6

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] How to enumerate the ClojureScript macros in ClojureScript REPL such as figwheel REPL?

2018-04-08 Thread Philos Kim
I found the way, so I want to share the tip with others here ( 
https://gist.github.com/philoskim/1d61574f69902c102d1a3c5c9112c6ba ).

2018년 4월 5일 목요일 오후 5시 23분 44초 UTC+9, Philos Kim 님의 말:
>
> I ran the follwoing code in the figwheel REPL and the result is an empty 
> list. 
>
> How can I enumerate the ClojureScript macros?
>
> dev:cljs.user=> (->> (ns-publics 'cljs.core)
>  vals
>  (filter #(get (meta %) :macro)))
> ()
>
>
> Thanks in advance.
>

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] How to enumerate the ClojureScript macros in ClojureScript REPL such as figwheel REPL?

2018-04-05 Thread Philos Kim
I ran the follwoing code in the figwheel REPL and the result is an empty 
list. 

How can I enumerate the ClojureScript macros?

dev:cljs.user=> (->> (ns-publics 'cljs.core)
 vals
 (filter #(get (meta %) :macro)))
()


Thanks in advance.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux 0.4.3 is out.

2018-03-17 Thread Philos Kim
Debux: Clojure and ClojureScript debugging library

v0.4.3

Changed: The same duplicate evaluated results are not printed by default. 
https://github.com/philoskim/debux#dup-option

Enhanced: The readability is enhanced for the looping constructs such as map, 
reduce, for, loop, and so on by inserting a blank line whenever iteration 
happens. https://github.com/philoskim/debux#enhanced-readability

I suggest that debux users should upgrade the old version to this version for 
the enhanced readability of printed results.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Best Book for Clojure

2018-03-13 Thread Philos Kim
This book is somewhat out-of-date but still the best book I have read on 
Clojure.
And I am so unhappy to see the second edition not come out.

Clojure Programming: Practical Lisp for the Java World

https://www.amazon.com/Clojure-Programming-Practical-Lisp-World/dp/1449394701/ref=sr_1_2?ie=UTF8=1520995738=8-2=clojure+programming

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Philos Kim
I have another question. Debux library supports ClojureScript as well. 
Similarly, I want to add my own function or macro to cljs.core as in Clojure. 
Can I use the same strategy in ClojureScript as in Clojure if I use it in the  
ClojureScript source code, not in REPL?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [?] Adding my own function to clojure.core namespace

2018-02-25 Thread Philos Kim
Thanks both of you!

I know it is not desirable but it is sometimes needed, especially in my case.

For example , I wrote debux ( https://github.com/philoskim/debux ) 
library. I want to use it only in development, not in production. If I 
'require' debux in source code to use it in development, I have to remove it in 
the source code manually in production.

I tested your recommendation in REPL and it worked. However could you tell me 
about how I can implement it in source code form, not in REPL?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] Adding my own function to clojure.core namespace

2018-02-24 Thread Philos Kim
Is there any way to add my own function to clojure.core namespace? Because I 
want to use that function globally without 'require' or 'use'. 

Thanks in advance.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] Adding my own function to clojure.core nanespace

2018-02-24 Thread Philos Kim
Is there any way to add my own function to clojutr.core namespace? Because I 
want to use that function without 'require' or 'use'.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure/ClojureScript debugging library debux 0.4.0 is out.

2017-12-17 Thread Philos Kim
Debux library is now upgraded to version 0.4.1.

2017년 12월 7일 목요일 오후 7시 34분 29초 UTC+9, Philos Kim 님의 말:
>
> * https://github.com/philoskim/debux
>
> * https://clojars.org/philoskim/debux
>

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Cider - emacs lisp errors reported

2017-12-10 Thread Philos Kim
I encountered the same problem some years ago. In my case the problem was 
solved by removing (require 'cl-lib) line in my init.el file. The cl-lib 
package defined when-let as well.
I hope that this will help you out!

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] Clojure/ClojureScript debugging library debux 0.4.0 is out.

2017-12-07 Thread Philos Kim
* https://github.com/philoskim/debux

* https://clojars.org/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux(Clojure/ClojureScript debugging library) 0.3.1 is out.

2017-06-28 Thread Philos Kim


I'm pleased to announce debux version 0.3.1.


# Debux is a library for debugging Clojure and ClojureScript.

# The new added feature is to show you every evaluated results of a form.


https://github.com/philoskim/debux


https://clojars.org/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux(Clojure/ClojureScript debugging library) 0.3.1 is out.

2017-06-28 Thread Philos Kim


I'm pleased to announce debux version 0.3.0.


# Debux is a library for debugging Clojure and ClojureScript.

# The new added feature is to show you every evaluated results of a form.


https://github.com/philoskim/debux


https://clojars.org/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux(Clojure/ClojureScript debugging library) 0.3.0 is out.

2017-06-28 Thread Philos Kim
I'm pleased to announce debux version 0.3.0.

# Debux is a library for debugging Clojure and ClojureScript.
# The new added feature is to show you every evaluated results of a form. 

https://github.com/philoskim/debux
https://clojars.org/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux 0.3.0 is out.

2017-06-28 Thread Philos Kim
I'm pleased to announce debux version 0.3.0.

# Debux is a library for debugging Clojure and ClojureScript.
# The new added feature is to show you every evaluated results of a form. 

https://github.com/philoskim/debux
https://clojars.org/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[?] cljs-devtools vs. dirac DevTools

2016-10-09 Thread Philos Kim
Could anyone explain the difference between cljs-devtools and dirac 
DevTools?

And which one to use when?

https://github.com/binaryage/cljs-devtools

https://github.com/binaryage/dirac

Many thanks in advance.

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clojure.spec question

2016-09-24 Thread Philos Kim
How can I define the following spec?

{"id" 1 "name" "john"}

1) The keys of a map must be the string type, not the keyword type.

2) The values must be fixed. Namely, the value of the key "id" must be 1 
and the value of the key "name" must be "john"

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I appreciate your reply.

The following is the entire code where I encountered this problem.
My intention was for debugging purpose to print the result of every nested 
expression in a form.


(ns debux.lab
  (:require (clojure [walk :as walk])))

;; For debugging
(defmacro dbg_
  [form]
  `(let [return# ~form]
 (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
 return#))

(def a 2)
(def b 3)
(def c 5)

(defn- dispatch
  [node]
  (cond
(list? node)
(do (eval `(dbg_ ~node))
node)

(and (symbol? node)
 (not (fn? (eval `~node
(do (eval `(dbg_ ~node))
node)

:else node))

(defn- tree-walk
  [tree]
  (walk/postwalk dispatch tree))


;; dbg for nested expressions
(defmacro dbgn [form]
  (tree-walk form))


;;; test samples

;; This works because every symbol is declared in global symbols
(dbgn (* c (+ a b)))
; >> dbg_: c => 5 <<
; >> dbg_: a => 2 <<
; >> dbg_: b => 3 <<
; >> dbg_: (+ a b) => 5 <<
; >> dbg_: (* c (+ a b)) => 25 <<


;; This works too, because literal syntax-quotes are used.
(let [a 10 b 20 c 30]
  (eval `(* ~c (+ ~a ~b
; => 900


;; But this doesn't work, because literal syntax-quotes can't be used in 
this case.
(let [a 10 b 20 c 30]
  (dbgn (* c (+ a b
;   2. Unhandled clojure.lang.Compiler$CompilerException
;  Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
;   
;   1. Caused by java.lang.UnsupportedOperationException
;  Can't eval locals
;   
;Compiler.java: 5943 
 clojure.lang.Compiler$LocalBindingExpr/eval
;Compiler.java: 6932  clojure.lang.Compiler/eval
;Compiler.java: 6890  clojure.lang.Compiler/eval
; core.clj: 3105  clojure.core/eval
; core.clj: 3101  clojure.core/eval
;..


Any suggestion in this case?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I appreciate your reply.

The following is the entire code where I encountered this problem.
My intention was for debugging purpose to print the result of every nested 
expression in a form.


(ns debux.lab
  (:require (clojure [walk :as walk])))

;; For internal debugging
(defmacro ^:private dbg_
  [form]
  `(let [return# ~form]
 (println ">> dbg_:" (pr-str '~form) "=>" return# "<<")
 return#))

(def a 2)
(def b 3)
(def c 5)

(defn- dispatch
  [node]
  (cond
(list? node)
(do (eval `(dbg_ ~node))
node)

(and (symbol? node)
 (not (fn? (eval `~node
(do (eval `(dbg_ ~node))
node)

:else node))

(defn- tree-walk
  [tree]
  (walk/postwalk dispatch tree))


;; dbg for nested expressions
(defmacro dbgn [form]
  (tree-walk form))


;;; test samples

;; This works because every symbol is declared in global symbols
(dbgn (* c (+ a b)))
; >> dbg_: c => 5 <<
; >> dbg_: a => 2 <<
; >> dbg_: b => 3 <<
; >> dbg_: (+ a b) => 5 <<
; >> dbg_: (* c (+ a b)) => 25 <<


;; This works too, because literal syntax-quotes are used.
(let [a 10 b 20 c 30]
  (eval `(* ~c (+ ~a ~b
; => 900


;; But this doesn't work, because literal syntax-quotes can't be used in 
this case.
(let [a 10 b 20 c 30]
  (dbgn (* c (+ a b
;   2. Unhandled clojure.lang.Compiler$CompilerException
;  Error compiling work/philos/debux/src/debux/lab.clj at (52:3)
;   
;   1. Caused by java.lang.UnsupportedOperationException
;  Can't eval locals
;   
;Compiler.java: 5943 
 clojure.lang.Compiler$LocalBindingExpr/eval
;Compiler.java: 6932  clojure.lang.Compiler/eval
;Compiler.java: 6890  clojure.lang.Compiler/eval
; core.clj: 3105  clojure.core/eval
; core.clj: 3101  clojure.core/eval
;..


Any suggestion in this case?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I need to evaluate local symbols using eval function in Clojure.

(def a 1)
(def b 2)

(let [a 10
  b 20]
  (eval '(+ a b)))
;=> 3

I expected the result to be 30, but the result is 3. I want to know why 
Clojure eval function doesn't evaluate the local symbols.

And any alternative to get around?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I evaluate local symbols using eval function in Clojure?

2016-09-06 Thread Philos Kim
I need to evaluate local symbols using eval function in Clojure.

(def a 1)
(def b 2)

(let [a 10
  b 20]
  (eval '(+ a b)))
;=> 3

I expected the result to be 30, but the reusult is 3. I want to know the 
reason why Clojure eval function doesn't evaluate the local symbols.

And any alternative to get around?

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] debux 0.2.1 is out

2016-05-16 Thread Philos Kim
Debux is a small but useful library for debugging Clojure and ClojureScript.

https://github.com/philoskim/debux

Change Logs

Version 0.2.1 (minor bug fixes):
Fixed: An error fixed when using (clog (->> .))
Fixed: An error fixed when using (dbg (let [[a & b] [10 20 30]] ..))
Added: break usage

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Understanding init (the zero arity function) for transducers.

2016-03-09 Thread Philos Kim
I wrote the next example to trace the inner workings of transducer. I hope 
that this will help.

The next filter-t(transducer), map-t(transducer) and conj-t(reducer) 
functions are excerpted from the filter, map and conj from clojure.core and 
then simplified and modified to focus on the understanding of the inner 
workings.

(defn filter-t
  [pred]
  ;; The first fn is a transducer. It receives the reducer rf and returns
  ;; the reducer(the second fn part of this code).  
  (fn [rf]
(fn
  ([]
   (let [r (rf)]
 (println "filter-t [] post: result =" r)
 r))
  ([result]
   (println "filter-t [result] pre: result =" result)
   (let [r (rf result)]
 (println "filter-t [result] post: result =" r)
 r))
  ([result input]
   (println "filter-t [result input] pre: result =" result ", input =" 
input)
   (let [r (if (pred input)
 (rf result input)
 result)]
 (println "filter-t [result input] post: result =" r)
 r)

(defn map-t
  [f]
  (fn [rf]
(fn
  ([]
   (let [r (rf)]
 (println "map-t [] post: result =" r)
 r))
  ([result]
   (println "map-t [result] pre: result =" result)
   (let [r (rf result)]
 (println "map-t [result] post: result =" r)
 r))
  ([result input]
   (println "map-t [result input] pre: result =" result ", input =" 
input)
   (let [r (rf result (f input))]
 (println "map-t [result input] post: result =" r)
 r)

(defn ^:static conj-t
  []
  ;; This is a reducer itself, not a transducer, because it doesn't receive 
the reducer
  ;; and return a reducer as a transducer.
  (fn
([]
 (println "conj-t []: result =" [])
 [])
([result]
 (println "conj-t [result]: result =" result)
 result)
([result input]
 (println "conj-t [result input] pre: result =" result ", input =" 
input)
 (let [r (. clojure.lang.RT (conj result input))]
   (println "conj-t [result input] post: retrun =" r)
   r) )))


The oupput is edited to facilitate the understandings.

(def xform  (comp (filter-t odd?) (map-t #(* % 10

(transduce xform (conj-t) [1 2 3 4 5])
;>> conj-t []: result = []
;
;   filter-t [result input] pre: result = [] , input = 1
; map-t [result input] pre: result = [] , input = 1
;   conj-t [result input] pre: result = [] , input = 10
;   conj-t [result input] post: retrun = [10]
; map-t [result input] post: result = [10]
;   filter-t [result input] post: result = [10]
;
;   filter-t [result input] pre: result = [10] , input = 2
;   filter-t [result input] post: result = [10]
;
;   filter-t [result input] pre: result = [10] , input = 3
; map-t [result input] pre: result = [10] , input = 3
;   conj-t [result input] pre: result = [10] , input = 30
;   conj-t [result input] post: retrun = [10 30]
; map-t [result input] post: result = [10 30]
;   filter-t [result input] post: result = [10 30]
;
;   filter-t [result input] pre: result = [10 30] , input = 4
;   filter-t [result input] post: result = [10 30]
;
;   filter-t [result input] pre: result = [10 30] , input = 5
; map-t [result input] pre: result = [10 30] , input = 5
;   conj-t [result input] pre: result = [10 30] , input = 50
;   conj-t [result input] post: retrun = [10 30 50]
; map-t [result input] post: result = [10 30 50]
;   filter-t [result input] post: result = [10 30 50]
;
;   filter-t [result] pre: result = [10 30 50]
; map-t [result] pre: result = [10 30 50]
;   conj-t [result]: result = [10 30 50]
; map-t [result] post: result = [10 30 50]
;   filter-t [result] post: result = [10 30 50]
;=> [10 30 50]

>From the above output, my conclusion is that the init part(with no 
argument) of reducer is called only in the last reducer(conj-t in this 
case) and never called in the reducers within the transducers(filter-t and 
map-t).

If you give the init value to the transduce function as follows,

(transduce xform (conj-t) [] [1 2 3 4 5])
;>> filter-t [result input] pre: result = [] , input = 1
; map-t [result input] pre: result = [] , input = 1
;   conj-t [result input] pre: result = [] , input = 10
;   conj-t [result input] post: retrun = [10]
; map-t [result input] post: result = [10]
;   filter-t [result input] post: result = [10]
;
;   filter-t [result input] pre: result = [10] , input = 2
;   filter-t [result input] post: result = [10]
;
;   filter-t [result input] pre: result = [10] , input = 3
; map-t [result input] pre: result = [10] , input = 3
;   conj-t [result input] pre: result = [10] , input = 30
;   conj-t [result input] post: retrun = [10 30]
; map-t [result input] post: result = [10 30]
;   filter-t [result input] post: result = [10 30]
;
;   filter-t [result input] pre: result = [10 30] , input = 4
;   filter-t [result input] post: result = [10 30]
;
;   filter-t [result input] pre: result = [10 30] 

[ANN] debux 0.2.0 is out

2016-02-24 Thread Philos Kim
Debux is a simple but useful library for debugging Clojure and 
ClojureScript. I wrote this library to debug my own Clojure(Script) code 
and to analyze other developer's Clojure(Script) code.

This version includes the new features of debugging ->, ->>, let and comp 
forms.

https://github.com/philoskim/debux

-- 
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 unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
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 receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.