Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
And yes, take-nth is what I wanted! -- 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

Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
that (:a :b) *really* looks like a seq -- 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 unsubscri

Re: Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
@Peter Great catch, thanks! I was scratching my head over this. -- 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

Problem with lazy seqs in macros

2018-02-05 Thread Divyansh Prakash
Hi! A while back, I was implementing some datastructures using functions and macros. While implementing hashmaps, I stumbled upon a problem: (ns hmap) (defmacro hmap [& kvs] "Returns an immutable hashmap. Keys must be compile-time constants." (if (even? (count kvs)) (let [tups (parti

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
I just added `goloop` and `goconsume` to the Clojure implementation, with version of `recur` called `gorecur`. *Example:* > repl> > (def ch (chan)) > #'functional-core-async.core/ch > > repl> > (goconsume [v ch] > (if (= :ok v) > (gorecur) > (println "done"))) > #object[java.util.conc

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
Just remembered that I did give an example in the README, a port of braveclojure's hotdog machine. (defn hot-dog-machine > [in out hot-dogs-left] > (when (> hot-dogs-left 0) > (go (if (= 3 input) > (go>! [out "hot dog"] > (hot-dog-machine in out (dec hot-dogs-left)

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
In fact, the JS implementation is much ahead of the Clojure version as of right now - with a better parking algorithm and `goconsume` for creating actors that park on read from a channel in an implicit loop. -- You received this message because you are subscribed to the Google Groups "Clojure"

Re: functional implementation of core.async primitives

2017-12-12 Thread Divyansh Prakash
Hi, @halgari! The JS port actually does have this, just haven't found the time to port it back. But basically we can define something like: (defn goloop* > [f initial-state] > (letfn [(recur+ [state] > (goloop* f state))] > (go > (f recur+ initial-state > > > (defmac

Re: functional implementation of core.async primitives

2017-11-22 Thread Divyansh Prakash
Thanks for the encouragement, Jay! I ported the library over to JS, and now we have coroutines in vanilla JavaScript! Porting it to other systems should be fairly straightforward. 😀 - Divyansh -- You received this message because you are subscribed to

Re: functional implementation of core.async primitives

2017-11-21 Thread Divyansh Prakash
Just a follow up. I have implemented parking versions of *!*, but (because I'm not a sorcerer like *@halgari*) they are rather simple and not as powerful as *core.async*'s versions. I now understand what more *core.async* is doing, and where my implementation falls short. I do believe I have a w

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
Actually, returns in ~1700ms if I increase buffer width to 1000 -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
The other example on that thread has stranger charesteristics: (defn bench [] > (time >(let [c (chan 100)] > (go >(dotimes [i 10] ;; doesn't return for 1e5, takes ~170ms for 1e4 > (>! c i)) >(close! c)) > (loop [i nil] >(if-let [x ( (re

Re: functional implementation of core.async primitives

2017-11-16 Thread Divyansh Prakash
Here 's a port of a core.async example that I was able to pull of the mailing list. Performance (in this particular case) seems to be the same. I'm trying out more examples as I find them. -- You received this message because you

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
Also, will this implementation result in most go blocks being autopromoted in a real application? -- 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 moder

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
(which also resolves this blocking go problem ... in a way) -- 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 fir

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
Hi! I tried resolving that but pre-emption of the current task turned out to be a really, really tough problem, and I believe that's why we need the core.async macros. Anyhow, I have updated the scheduler to autopromote go blocks into actual JVM threads if they block for more than 10ms - poor

Re: functional implementation of core.async primitives

2017-11-15 Thread Divyansh Prakash
Hi! Thank you for your feedback! I've made the following changes to my implementation : - bounded channels with backpressure - proper thread synchronization - thread blocks that run on actual threads (unlike go blocks) TODO: - alts! - preserve thread local bindings in `go` blocks (`thread` too?)

clojure.core/bean throws when passed an empty list

2016-10-04 Thread Divyansh Prakash
Is this desired behaviour? user=> (bean []) {:class clojure.lang.PersistentVector, :empty true} user=> (bean {}) {:class clojure.lang.PersistentArrayMap, :empty true} user=> (bean ()) IllegalAccessException Class clojure.core$bean$fn__5975$fn__5976 can not access a member of class clojure.lang.

Re: Trouble using r/fold to optimise a reduce

2016-04-03 Thread Divyansh Prakash
Thanks a lot for taking the time out to explain this stuff in detail! Will go through your solution shortly. On Sunday, April 3, 2016 at 12:02:48 PM UTC+5:30, Francis Avila wrote: > > I had some fun with playing around with faster solutions. > https://gist.github.com/favila/0573e3f644dea252bdaae

Re: Trouble using r/fold to optimise a reduce

2016-04-02 Thread Divyansh Prakash
Updated code here . -- 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 - plea

Re: Trouble using r/fold to optimise a reduce

2016-04-02 Thread Divyansh Prakash
orithm could be parallelized > because the order in which you apply the toggle operation matters! I > suspect if you make the mapv change I suggest you will get different final > answers. > > > > > > > On Saturday, April 2, 2016 at 3:24:47 PM UTC-5, Divyansh

Re: Trouble using r/fold to optimise a reduce

2016-04-02 Thread Divyansh Prakash
atters! I > suspect if you make the mapv change I suggest you will get different final > answers. > > > > > > > On Saturday, April 2, 2016 at 3:24:47 PM UTC-5, Divyansh Prakash wrote: >> >> Hi! >> I'm solving the problem described here <http://adve

Re: Trouble using r/fold to optimise a reduce

2016-04-02 Thread Divyansh Prakash
ed > because the order in which you apply the toggle operation matters! I > suspect if you make the mapv change I suggest you will get different final > answers. > > > > > > > On Saturday, April 2, 2016 at 3:24:47 PM UTC-5, Divyansh Prakash wrote: >> >> H

Trouble using r/fold to optimise a reduce

2016-04-02 Thread Divyansh Prakash
Hi! I'm solving the problem described here . I've got the solution , but it takes ~50 s to compute. I tried optimising it by replacing the main reduce operation with r/fold, but it doesn't s

Show: Naive data fitting with Nyarlathotep

2015-08-14 Thread Divyansh Prakash
Hey! Nyarlathotep is a tiny mathematical function generator that can be used as a (very naive) data fitting tool. It generates random functions and tests them against provided constraints. I don't think it's of any practical use, but it is fascinating to

Re: core.async: implementing pi.go

2015-08-03 Thread Divyansh Prakash
> > does maya automatically handle operator precedence? > maya always evals from left to right. (maya 1 + 5 :as six, six * 2 :as twelve, twelve / 3 * 2) ;=> 8 > > - Divyansh -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, s

Re: core.async: implementing pi.go

2015-08-02 Thread Divyansh Prakash
Makes sense. By the way - I've refactored my code to not use a go block inside 'term', and made it much more readable (IMO) than before using my maya library . I'm telling you this because I'm

Re: core.async: implementing pi.go

2015-08-02 Thread Divyansh Prakash
Hey, puzzler! Thanks for the detailed response. Just changing (chan) to (chan n) actually worked! I get your displeasure with how 'term' is implemented. That's not how I generally code. I'm very new to core.async and was aiming for a direct translation of the Go code. I do get a little carrie

core.async: implementing pi.go

2015-08-02 Thread Divyansh Prakash
I came across pi.go in the examples for go-lang. I've been trying to replicate it with core.async, and this is what I have till now: (defn term [ch k] > (go (>! ch (-> 4.0 > (* (Math/pow -1 k)) > (/ (-> k (* 2) (+ 1))

Re: Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Thanks for the response, everyone. My Procfile says: > worker: lein trampoline run > I'm not binding to any port because my app doesn't require it. How do I do so, though? Will it be available as a part of lein-environ? -- You received this message because you are subscribed to the Google Gro

Re: Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Thanks for the response, everyone. My Procfile says: > worker: lein trampoline run > I'm not binding to any port because my app doesn't require it. How do I do so, though? Will it be available as a part of lein-environ? -- You received this message because you are subscribed to the Google Gr

Twitter bot crashing on Heroku

2015-07-27 Thread Divyansh Prakash
Hi! I had written a poetry generator sometime back and wanted to convert it into a Twitter bot. I followed this tutorial to do so. You can find my code here . The bot's working fine

maya - A DSL for math and numerical stuff

2015-01-07 Thread Divyansh Prakash
maya - A DSL for math and numerical stuff. https://gist.github.com/divs1210/b4fcbd48d7697dfd8850#file-maya -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members

Re: CljOS - An OOP system on Clojure

2014-10-26 Thread Divyansh Prakash
Thank you! Clojure is a brilliant language, and this project was supposed to prove (mostly to myself) that it deserves the attention I'm devoting to it. I cannot even imagine doing something similar in any other language I know. I'm not saying it wouldn't be possible, but it certainly won't fit

Re: Demoralising experience trying to install on Win 7

2014-10-25 Thread Divyansh Prakash
I know this is not a real solution, but you can download Clooj and get started right away. It's a pretty decent environment, and you can use it till you have a proper install. -- You received this message because you are subscribed to the Google Groups

CljOS - An OOP system on Clojure

2014-10-24 Thread Divyansh Prakash
CljOS is a single-inheritance OOP system in Clojure that I wrote over the weekend. Would love some feedback. :) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Writing games in Clojure using Kilvish Game Engine

2014-07-14 Thread Divyansh Prakash
Kilvish is a simple, lightweight Game Engine that I've been working on, that is written as an abstraction over awt/swing and is intended for absolute beginners. There's an example that comes bundled with it (BricksNBall

Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
Sorry if you feel that way. Thought i could share my thoughts and start an interesting discussion. That is what the group is for. You are obviously free to skip anything that doesn't interest you. That was the prime reason for the concise title. I have no intentions of misleading anyone. -- You

Re: Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
(and rant about other stuff I don't know a whole lot about) -- 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 fir

Clojure:Lisp :: LSD:Meditation

2014-06-12 Thread Divyansh Prakash
I compare Clojure to acid in this rant. -- 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 ne

Re: Cleaner solution, anyone?

2014-05-02 Thread Divyansh Prakash
I've been trying out my code in both Clojure and ClojureScript REPLs. 1. Ratio not being a type in js might cause inconsistencies if not used carefully. (for eg in a web app that uses both clj and cljscript) 2. Lazy sequences in Clojure are lazy in

Re: Cleaner solution, anyone?

2014-05-02 Thread Divyansh Prakash
Exactly! By the way, I posted the same questionto stackoverflow. A. Webb seems to agree with Steve, showing a version using reduced. Thank you for the response, guys! On Friday, May 2, 2014 1:38:09 AM UTC+5:30, Guru De

Cleaner solution, anyone?

2014-05-01 Thread Divyansh Prakash
Hey! I wrote a blog post discussing Thomson's Paradox, and simulated it in Clojure- http://pizzaforthought.blogspot.in/2014/05/and-infinity-beyond.html The *state* function defined towards the end is not very functional. Could someone guide me towards a cleaner approach? Also, I can't find

Re: Update

2014-04-29 Thread Divyansh Prakash
Check out my previous reply. The parrot vm provides gc and everything, But still the author defines lambda primitives in c, and then builds over it. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegr

Re: Update

2014-04-29 Thread Divyansh Prakash
Why not emit bytecode directly from the language? Couldn't this potentially lead to tons of specialized optimizing macros? -- 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 f

Re: Update

2014-04-29 Thread Divyansh Prakash
I looked into a port of Clojure to Parrot, and it basically does the same thing . -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Re: Update

2014-04-29 Thread Divyansh Prakash
Thank you for the explanation. What if I target a non-OO-centric VM (like Parrot or LLVM)? I've noticed that most Lisp implementations define lambda calculus primitives, and then use those as the core. I wonder what would be if we had bytecode primitives, and defined everything else on top of th

Re: Update

2014-04-29 Thread Divyansh Prakash
Why are Clojure features defined in terms of Java classes, instead of as bytecode primitives? For eg: Cons is a class containing two objects: first and rest. Is this only to achieve Java interoperability, or is there more to it? -- You received this message because you are subscribed to the Goog

Re: Update

2014-04-28 Thread Divyansh Prakash
> > Thanks! > Exactly what I was looking for. -- 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

Re: Update

2014-04-28 Thread Divyansh Prakash
Jasmin would be a much better choice, btw, because it could be used as a dependency in Clojure. -- 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 moderat

Update

2014-04-28 Thread Divyansh Prakash
---IDEA--- I was wondering if we could have a bytecode DSL that would map directly to JVM assembler, using either Jasmin or Krakatau . Then we could define primitives using these bytecode instructions. For eg: (defroutine

Starting work on a new dialect on top of the JVM

2014-04-27 Thread Divyansh Prakash
Hey! I have some ideas that I will be talking about here. Here's a little introduction. http://pizzaforthought.blogspot.in/2014/04/lisp-teleology.html -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Quil for ClojureScript

2014-03-11 Thread Divyansh Prakash
Hello! I am a Java developer, and the author of 3Coffee, a 2D Game Engine (with custom inbuilt physics) that I wrote some 2 years back. I stumbled across Clojure while trying to solve one of the *many* threading issues I seemed to have with swing. I have b