Re: Critiques of my-flatten which uses CPS

2014-07-16 Thread Mark Engelberg
It's worth understanding how to go back and forth between accumulator-style
and a lazy construction.  You can convert the above non-lazy accumulator
version into a similar version that is lazy but has no risk of stack
overflow in the realization of that lazy flattened list:

(defn my-flatten
  [xs]
  (if (empty? xs) ()
(let [x (first xs), ys (rest xs)]
  (if (sequential? x)
(if (seq x)
  (recur (cons (first x) (cons (rest x) ys)))
  (recur ys))
(lazy-seq (cons x (my-flatten ys)))

Basically, you just get rid of the accumulator, and in the place where you
would have conj'd in the next atomic element, you just build the lazy
sequence.

-- 
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: Re-upload corrupted Rich Hickey video?

2014-07-16 Thread TP
Download the file via some youtube downloader. The downloaded file is not
corrupted.


On Tue, Jul 15, 2014 at 4:46 PM, Herwig Hochleitner hhochleit...@gmail.com
wrote:

 2014-07-16 0:18 GMT+02:00 gvim gvi...@gmail.com:

 Clojure for Lisp Programmers Part 1 by Rich Hickey:

 http://www.youtube.com/watch?v=cPNkH-7PRTk

  seems to have become corrupted. Can anyone re-upload the original?


 I can confirm that it's cut off at 6:35 in all resolutions. I hope
 ClojureTV still has the original.

 --
 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.


-- 
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] Brute 0.3.0 - A lightweight Entity Component System library for writing games

2014-07-16 Thread Mark Mandel
Brute is a simple and lightweight Entity Component System library for
writing games with Clojure and now also **ClojureScript**.

Big thanks to Martin Janiczek https://github.com/Janiczek for porting
Brute over to CLJX and making everything work.

There are also some new functions - including:

   - An implementation of (update-function ... ) to make functionally
   changing component state much easier
   - Ability to add throttled system functions that only fire every n
   milliseconds.

Full blog post on changes:
http://www.compoundtheory.com/brute-0-3-0-now-supporting-clojurescript/

Project can be found on Github at:
https://github.com/markmandel/brute

As always feedback and pull requests are welcome.

-- 
E: mark.man...@gmail.com
T: http://www.twitter.com/neurotic
W: www.compoundtheory.com

2 Devs from Down Under Podcast
http://www.2ddu.com/

-- 
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] tools.namespace 0.2.5

2014-07-16 Thread Stuart Sierra
*tools.namespace:* finding, parsing, and reloading Clojure
namespaces in correct dependency order

https://github.com/clojure/tools.namespace

*Release 0.2.5*

Leiningen dependency:

[org.clojure/tools.namespace 0.2.5]

This release contains bugfixes, performance enhancements,
and minor feature enhancements:

  * New `clojure.tools.namespace.repl/clear` empties the
state of the REPL dependency tracker. This can help
repair the dependency tracker after a failed load or a
circular dependency error.

  * Enhancement [TNS-19]: `deps-from-ns-decl` should return
an empty set instead of nil. This may be a breaking
change for some but is consistent with the original
docstring.

  * Enhancement [TNS-18]: Compute transitive dependencies in
linear time. Thanks to Andy Fingerhut.

  * Enhancement [TNS-17]: The `ns` form doesn't need to be
the first top-level form in a file.

  * Fix [TNS-16]: Don't depend on specific hash ordering in
tests. Exposed by new hash functions in Clojure 1.6.0.

  * Fix [TNS-15]: Handle spaces in classpath directories
(old `clojure.tools.namespace`)

  * Fix [TNS-12]: Duplicate definition of `jar-file?`

tools.namespace is a Clojure contrib project.
http://dev.clojure.org/display/doc/Clojure+Contrib

-- 
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] monads 0.2.2

2014-07-16 Thread Ben Wolfson
After a surprisingly long time I'm releasing a new version of my monads
library, focussed on expressivity and correctness:

https://github.com/bwo/monads

Leiningen:

[bwo/monads 0.2.2]


Improvements from 0.1.0 include:

- change from maps to protocols for monad implementations, which has
increased flexibility and speed (this library is once again a little faster
than morph)

- all monad implementations interoperate with algo.generic.functor

- monad transformers automatically lift operations from inner monads, if
they're supported

- a combined reader/writer/state monad (and transformer) was introduced,
and the (faulty) list-t monad transformer was removed

- improvements to call/cc, shift, and reset for the continuation monad

- an applicative functor protocol was introduced, and implementations
provided for several existing types and all monad implementations.

Also, the `mdo` syntax macro was abstracted out and can now accept an
arbitrary user-provided function for doing monadic binds, which should mean
that it can be used with other libraries, though I haven't actually tested
this.

-- 
Ben Wolfson
Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure.
[Larousse, Drink entry]

-- 
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] tools.namespace 0.2.5

2014-07-16 Thread Ambrose Bonnaire-Sergeant
Fantastic! Thanks Stuart!

Ambrose


On Wed, Jul 16, 2014 at 9:10 PM, Stuart Sierra m...@stuartsierra.com
wrote:

 *tools.namespace:* finding, parsing, and reloading Clojure
 namespaces in correct dependency order

 https://github.com/clojure/tools.namespace

 *Release 0.2.5*

 Leiningen dependency:

 [org.clojure/tools.namespace 0.2.5]

 This release contains bugfixes, performance enhancements,
 and minor feature enhancements:

   * New `clojure.tools.namespace.repl/clear` empties the
 state of the REPL dependency tracker. This can help
 repair the dependency tracker after a failed load or a
 circular dependency error.

   * Enhancement [TNS-19]: `deps-from-ns-decl` should return
 an empty set instead of nil. This may be a breaking
 change for some but is consistent with the original
 docstring.

   * Enhancement [TNS-18]: Compute transitive dependencies in
 linear time. Thanks to Andy Fingerhut.

   * Enhancement [TNS-17]: The `ns` form doesn't need to be
 the first top-level form in a file.

   * Fix [TNS-16]: Don't depend on specific hash ordering in
 tests. Exposed by new hash functions in Clojure 1.6.0.

   * Fix [TNS-15]: Handle spaces in classpath directories
 (old `clojure.tools.namespace`)

   * Fix [TNS-12]: Duplicate definition of `jar-file?`

 tools.namespace is a Clojure contrib project.
 http://dev.clojure.org/display/doc/Clojure+Contrib


  --
 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.


-- 
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.


handling only a part of a hash-map

2014-07-16 Thread Christian
Hi,

I'm just beginning with clojure.

;(let [conn (mg/connect)
; db   (mg/get-db conn throughput)
; coll clojure_throughput_src]
;;; with a query, as Clojure maps
;  ( doseq [item (mc/find-maps db coll {})]
;(println
;  (get_timeslot
;(get_dt
;  ( get item :ts))

In a mongodb collection I have a timestamp and an id. I'll transform the 
timestamp which works fine.
But I'm struggle with getting  the id  , too   - let  it untransformed and 
going on with this hash-map result.

Thanks in advance
Christian




-- 
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.


NPE on ((print))

2014-07-16 Thread vag . vagoff
Hi!

user= ((print))
NullPointerException   user/eval1 (NO_SOURCE_FILE:1)

Is that behaviour indended?

-- 
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: NPE on ((print))

2014-07-16 Thread Ambrose Bonnaire-Sergeant
Hi,

Parenthesis are for function invocations in Clojure. ((print)) calls the
result of print (which is null)
aka. nil, which results in a NPE.

Thanks,
Ambrose


On Thu, Jul 17, 2014 at 1:20 AM, vag.vag...@gmail.com wrote:

 Hi!

 user= ((print))
 NullPointerException   user/eval1 (NO_SOURCE_FILE:1)

 Is that behaviour indended?

 --
 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.


-- 
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: handling only a part of a hash-map

2014-07-16 Thread Mike Fikes
select-keys makes it easy to extract a portion of a map:

(select-keys {:id 1 :ts 2 :ignore 3} [:id :ts])
= {:ts 2, :id 1}

-- 
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.


[Call for Papers] 2014 Scheme and Functional Programming Workshop

2014-07-16 Thread Jason Hemann
[Apologies for duplication from cross-postings.]

Important Note: This year's Scheme and Functional Programming Workshop 
is co-located with Clojure/conj. Clojure-related papers are encouraged, as 
are 
first-time and non-academic authors. -- JBH

DEADLINE: 5 September 2014, (23:59 UTC-12)
WEBSITE: http://homes.soic.indiana.edu/jhemann/scheme-14/
LOCATION: Washington, DC (co-located with Clojure/conj)
DATE: 19 November 2014

The 2014 Scheme and Functional Programming Workshop is calling for
submissions.

Submissions related to Scheme and functional programming are welcome
and encouraged. Topics of interest include but are not limited to:

- Program-development environments, debugging, testing
- Implementation (interpreters, compilers, tools, benchmarks, etc)
- Syntax, macros, and hygiene
- Distributed computing, concurrency, parallelism
- Interoperability with other languages, FFIs
- Continuations, modules, object systems, types
- Theory, formal semantics, correctness
- History, evolution and standardization of Scheme
- Applications, experience and industrial uses of Scheme
- Education
- Scheme pearls (elegant, instructive uses of Scheme)

We also welcome papers related to dynamic or multiparadigmatic
languages and programming techniques.

Full papers are due 5 September 2014.
Authors will be notified by 10 October 2014.
Camera-ready versions are due 24 Oct 2014.
All deadlines are (23:59 UTC-12), Anywhere on Earth.

For more information, please see:

http://homes.soic.indiana.edu/jhemann/scheme-14/

Best,

Jason Hemann, 
Organizer, Scheme 14

-- 
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.


casting error

2014-07-16 Thread Brian Craft
Trying to eliminate a reflection warning, I put a type hint on a function, 
like

(defn foo ^PStatement [] ...)

which compiles without the reflection warnings, but at run time I get

ClassCastException java.lang.ClassCastException: cavm.h2.PStatement cannot 
be cast to cavm.h2.PStatement

What does this mean? PStatement is a defrecord type.

-- 
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.


TBNL: power tool for Android system hacking tool in Clojure

2014-07-16 Thread Wei Peng
Hi All,

I want to share with you an Android system hacking tool that I have been 
working on the past few weeks that is written entirely in Clojure

github repo: https://github.com/pw4ever/tbnl
brief video tour: http://youtu.be/Hvzl_RK5JH0 http://youtu.be/Hvzl_RK5JH0

Two features highlighted in the video are:
* *root (in contrast to app domain) Clojure REPL on Android*. The video 
tour shows briefly some useful things that we can do with it.
* Visualizing Activity activation of a live Android session.

It is a quite extensible framework that delegates functionality 
implementation to plugins. The code is quite modular and straightforward to 
extend.

If you have time, give it a try. I'd love hear from you how it can be 
improved.

Wei.

-- 
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: casting error

2014-07-16 Thread Brian Craft
Apparently this is due to a class loader problem.

I moved it into a different file to try to avoid the problem. However I'm 
now finding that nothing referencing foo will compile, throwing this error:

CompilerException java.lang.IllegalArgumentException: Unable to resolve 
classname: PStatement

No idea what to do with this. Is it not possible to type hint methods 
returning records?

On Wednesday, July 16, 2014 4:21:22 PM UTC-7, Brian Craft wrote:

 Trying to eliminate a reflection warning, I put a type hint on a function, 
 like

 (defn foo ^PStatement [] ...)

 which compiles without the reflection warnings, but at run time I get

 ClassCastException java.lang.ClassCastException: cavm.h2.PStatement cannot 
 be cast to cavm.h2.PStatement

 What does this mean? PStatement is a defrecord type.


-- 
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: casting error

2014-07-16 Thread Andy Fingerhut
Try fully qualifying the class name in the return type hint.

Might be the same symptom as in this ticket:
http://dev.clojure.org/jira/browse/CLJ-1232

Andy


On Wed, Jul 16, 2014 at 7:18 PM, Brian Craft craft.br...@gmail.com wrote:

 Apparently this is due to a class loader problem.

 I moved it into a different file to try to avoid the problem. However I'm
 now finding that nothing referencing foo will compile, throwing this error:

 CompilerException java.lang.IllegalArgumentException: Unable to resolve
 classname: PStatement

 No idea what to do with this. Is it not possible to type hint methods
 returning records?

 On Wednesday, July 16, 2014 4:21:22 PM UTC-7, Brian Craft wrote:

 Trying to eliminate a reflection warning, I put a type hint on a
 function, like

 (defn foo ^PStatement [] ...)

 which compiles without the reflection warnings, but at run time I get

 ClassCastException java.lang.ClassCastException: cavm.h2.PStatement
 cannot be cast to cavm.h2.PStatement

 What does this mean? PStatement is a defrecord type.

  --
 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.


-- 
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: Critiques of my-flatten which uses CPS

2014-07-16 Thread Mark P
Interesting - thank you!

Good to know about into as a way to achieve a non-lazy concat - in 
conjunction with a vector.

I like your accumulator version - morphing the structure of the input as 
you go to achieve the desired result.

I've come up with another version, that passes through both a result so 
far accumulator and a still to be computed stack.  It is very much 
non-lazy, but that's okay in some applications (a performance feature 
even!).  Here it is...

(defn my-accandstackbased-flatten
  [xs]
  (letfn [(flatten-accandstack [xs accvec stackvec]
(if (empty? xs)
  (if (empty? stackvec)
accvec
(recur (peek stackvec) accvec (pop stackvec)))
  (let [x (first xs), ys (next xs)]
(if (sequential? x)
  (recur x accvec (conj stackvec ys))
  (recur ys (conj accvec x) stackvec)]
(seq (flatten-accandstack xs [] []

This has nice recur behaviour and doesn't mess too much with the structure 
of the input nested lists.  In the case of flatten, retaining structure is 
not important (as you nicely illustrated), but there are generalizations of 
this kind of function where retaining structure becomes more important.

Now here's the thing...  In the above, my stackvec is sort of like a 
continuation.  It contains a stack of computation to be performed later on. 
 That sounds very much like a continuation to me (though I am still in the 
process of getting my head around this stuff).  So I've thought, surely I 
could write an acc and cps version of my-flatten?  Here is what I came up 
with...

(defn my-accandcpsbased-flatten
  [xs]
  (letfn [(flatten-accandcps [xs accvec k]
(if (empty? xs)
  (k accvec)
  (let [x (first xs), ys (next xs)]
(if (sequential? x)
  (recur x accvec (fn [v] (flatten-accandcps ys [] (fn [w] 
(k (into v w))
  (recur ys (conj accvec x) k)]
(seq (flatten-accandcps xs [] identity
 
And I could do the trick you showed me with thunks and a trampoline, if I 
wanted to make it completely stack-avoiding.

What does this show?  I'm not sure.

Presumably the acc and stack version is the most efficient as it uses recur 
everywhere?

The structure of the continuation I pass in with the acc and cps version 
is very similar in complexity to the continuation I passed as part of my 
original cps implementation.  So where's the gain?  I guess the inclusion 
of an accvec means that continuations are generated less frequently so that 
the overall size and execution time of continuations is smaller?  And it is 
an improvement over my earlier aps version that used only an acc vector - 
because this version has everything in tail-call position and is amenable 
to trampolining.

Is this attempt at analysis reasonable?  Is there anything else worth 
observing etc?

Presumably I could make the acc and cps above more lazy using concat, 
cons and lazy-seq.  I'd need to think about how easy/hard it would be to 
make my acc and stack version as lazy.

Thanks again for your helpful comments and examples.

-- 
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: casting error

2014-07-16 Thread Brian Craft
That does, in fact, fix the compile issue. Thanks!

The cast error, however, persists. It's something to do with reloading the 
namespace with the defrecord. Once it happens, it takes a lein clean to 
clear. After that it works w/o error until the namespace is reloaded. It's 
something to do with referencing the defrecord from another namespace, or 
aot compiling. So far I haven't found a solution. It appears that an aot 
compiled file can't reference a function with a type hint for a defrecord 
if the namespace with that defrecord is then dynamically reloaded. Or 
something. It all looks exceedingly complex at this point.


On Wednesday, July 16, 2014 8:36:35 PM UTC-7, Andy Fingerhut wrote:

 Try fully qualifying the class name in the return type hint.

 Might be the same symptom as in this ticket: 
 http://dev.clojure.org/jira/browse/CLJ-1232

 Andy


 On Wed, Jul 16, 2014 at 7:18 PM, Brian Craft craft...@gmail.com 
 javascript: wrote:

 Apparently this is due to a class loader problem.

 I moved it into a different file to try to avoid the problem. However I'm 
 now finding that nothing referencing foo will compile, throwing this error:

 CompilerException java.lang.IllegalArgumentException: Unable to resolve 
 classname: PStatement

 No idea what to do with this. Is it not possible to type hint methods 
 returning records?

 On Wednesday, July 16, 2014 4:21:22 PM UTC-7, Brian Craft wrote:

 Trying to eliminate a reflection warning, I put a type hint on a 
 function, like

 (defn foo ^PStatement [] ...)

 which compiles without the reflection warnings, but at run time I get

 ClassCastException java.lang.ClassCastException: cavm.h2.PStatement 
 cannot be cast to cavm.h2.PStatement

 What does this mean? PStatement is a defrecord type.

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com 
 javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 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+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
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: casting error

2014-07-16 Thread Brian Craft
I have a wonky work-around. The file that is aot compiled depends on the 
file with the defrecord reference. I eliminated the direct dependency and 
exported a function that does an alter-root-var. So the provider injects 
the required value into the dependent.

On Wednesday, July 16, 2014 9:33:52 PM UTC-7, Brian Craft wrote:

 That does, in fact, fix the compile issue. Thanks!

 The cast error, however, persists. It's something to do with reloading the 
 namespace with the defrecord. Once it happens, it takes a lein clean to 
 clear. After that it works w/o error until the namespace is reloaded. It's 
 something to do with referencing the defrecord from another namespace, or 
 aot compiling. So far I haven't found a solution. It appears that an aot 
 compiled file can't reference a function with a type hint for a defrecord 
 if the namespace with that defrecord is then dynamically reloaded. Or 
 something. It all looks exceedingly complex at this point.


 On Wednesday, July 16, 2014 8:36:35 PM UTC-7, Andy Fingerhut wrote:

 Try fully qualifying the class name in the return type hint.

 Might be the same symptom as in this ticket: 
 http://dev.clojure.org/jira/browse/CLJ-1232

 Andy


 On Wed, Jul 16, 2014 at 7:18 PM, Brian Craft craft...@gmail.com wrote:

 Apparently this is due to a class loader problem.

 I moved it into a different file to try to avoid the problem. However 
 I'm now finding that nothing referencing foo will compile, throwing this 
 error:

 CompilerException java.lang.IllegalArgumentException: Unable to resolve 
 classname: PStatement

 No idea what to do with this. Is it not possible to type hint methods 
 returning records?

 On Wednesday, July 16, 2014 4:21:22 PM UTC-7, Brian Craft wrote:

 Trying to eliminate a reflection warning, I put a type hint on a 
 function, like

 (defn foo ^PStatement [] ...)

 which compiles without the reflection warnings, but at run time I get

 ClassCastException java.lang.ClassCastException: cavm.h2.PStatement 
 cannot be cast to cavm.h2.PStatement

 What does this mean? PStatement is a defrecord type.

  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
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.