Re: Aparapi

2011-07-18 Thread Gary
t) that we plan to OpenSource Aparapi in Q311. It would be great to work with folks with intimate knowledge of these alternate JVM languages to make them work with Aparapi. Gary On Jul 15, 12:17 pm, cej38 wrote: > Hello. >   Has anyone looked at using AMD'sAparapiAPI from within Cloju

Re: Thoughts on CUDA + Clojure

2011-09-14 Thread Gary
The Aparapi project was open sourced today take a look at http://aparapi.googlecode.com. Although previous comments had listed concerns with Aparapi code restrictions, it would be great to work with developers of languages like Clojure to see what features of Aparapi might be useful. Gary On

Erlang like environment

2010-04-14 Thread gary ng
Hi, I just start to learn about clojure and is wondering if there is any erlang like environment for clojure ? By that, I mean not just the messaging passing(which as far as I can tell for clojure is within the same process) but its live update and sending symbols(and as far as I know functions as

Re: Which version of Netbeans to use Compojure on OSX?

2010-04-22 Thread gary ng
I would choose the one with glassfish which includes the web app things that even though you may not need immediately(if compojure comes with embedded jetty) will be very likely in the future when you use other app containers(be it GAE or tomcat etc.) I picked the base Java SE version and needs to

idiomatic clojure of this java style ?

2010-04-24 Thread gary ng
Hi, As a newbie learning clojure, I would like to code in clojure rather than 'java disguised as clojure' and I am wondering what would it looks like for the following typical java(shown below) implementation. which has: 1. a static class member for the logger 2. and typical imperative style codi

Re: idiomatic clojure of this java style ?

2010-04-25 Thread gary ng
On Sat, Apr 24, 2010 at 12:56 PM, Allen Johnson wrote: > Here's my attempt. I don't think you can do much about the imperative > style when you are calling Java APIs unless someone was nice and wrote > a clojure wrapper. But I'm just a n00b. > thanks for the help. When deployed to GAE, I got the

clojure.contrib.logging and Google App Engine

2010-04-25 Thread gary ng
Hi, I am trying to use clojure to write servlets for GAE and is encountering problem with clojure.contrib.logging. When trying to use the logging function, I get the following exception: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory at java.net.URLClassLoader$1.run(URLC

Re: clojure.contrib.logging and Google App Engine

2010-04-25 Thread gary ng
On Sun, Apr 25, 2010 at 11:08 AM, gary ng wrote: > Hi, > > I am trying to use clojure to write servlets for GAE and is encountering > problem with clojure.contrib.logging. When trying to use the logging > function, I get the following exception: > > java.lang.C

Re: clojure.contrib.logging and Google App Engine

2010-04-25 Thread gary ng
On Sun, Apr 25, 2010 at 1:17 PM, Allen Johnson wrote: > > What seems to be happening is that when I build my 'gen-class' package, > the > > class is nailed down even though logging.clj itself is not gen-classed. > > I'm not familiar with GAE but as a workaround can you include the > commons-loggin

Re: clojure.contrib.logging and Google App Engine

2010-04-25 Thread gary ng
On Sun, Apr 25, 2010 at 3:34 PM, ataggart wrote: > Was the problem you're having occurring with the latest version of > cc.logging (the one that uses eval)? > > The logging macros do not emit calls to the logging implementation, > but rather to c.c.logging functions that are implemented at runtim

Any window user familiar with clojure-contrib development ?

2010-04-26 Thread gary ng
Hi, I am wondering if there is any windows user who is familiar with clojure-contrib project. The reason I asked is that I encountered quite some issues when trying to build my own copy of clojure-contrib(on windows). That includes: 1. I cannot clone http://github.com/richhickey/clojure-contrib.

Re: clojure.contrib.logging and Google App Engine

2010-04-26 Thread gary ng
On Sun, Apr 25, 2010 at 4:47 PM, ataggart wrote: > Yeah, the fix-patch was submitted prior to the final release of 1.1.0, > but alas none of those with the power to actually commit the patch got > around to it until it was too late. > > I have built the 1.2.0-snapshot which seems to be even worse

Re: clojure.contrib.logging and Google App Engine

2010-04-26 Thread gary ng
On Mon, Apr 26, 2010 at 6:26 PM, gary ng wrote: > > > On Sun, Apr 25, 2010 at 4:47 PM, ataggart wrote: > >> Yeah, the fix-patch was submitted prior to the final release of 1.1.0, >> but alas none of those with the power to actually commit the patch got >> arou

what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
Clojure 1.2.0-master-SNAPSHOT user=> (use `clojure.contrib.string) java.lang.IllegalStateException: repeat already refers to: #'clojure.core/repeat in namespace: user (NO_SOURCE_FILE:0) By going through the source, I see c.c.s deliberately exclude certain symbols but don't know how to do it in th

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
On Thu, Apr 29, 2010 at 7:24 PM, ataggart wrote: > user=> (defn repeat [x] x) > java.lang.Exception: Name conflict, can't def repeat because > namespace: user refers to:#'clojure.core/repeat (NO_SOURCE_FILE:1) > user=> (ns my.ns (:refer-clojure :exclude [repeat])) > nil > my.ns=> (defn repeat [x]

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-29 Thread gary ng
On Thu, Apr 29, 2010 at 9:11 PM, Meikel Brandmeyer wrote: > > c.c.string is not designed to be used like that. Use require plus an > alias: (require '[clojure.contrib.string :as s]). Then repeat is the > core repeat and s/repeat is the string repeat. > > What would be the use case of 'use' then ?

Re: what is wrong with (use `clojure.contrib.string) ?

2010-04-30 Thread gary ng
On Thu, Apr 29, 2010 at 10:43 PM, David Nolen wrote: > My rule of thumb is: > > use + :only > require + :as > > I believe this should be documented as the 'suggested usage'. As contrary to Python where 'from module import *'(which is 'use' in clojure) is right in there saying 'you know what you ar

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
I have a question related to this. (ns foo (:use clojure.core)) (defn + [x y] x) '+' is already referred because of the use and is an error right now. But this is a legitimate use of the symbol as 'foo' can be matrix and matrix addition is different from standard number addition. Or is there a b

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
On Wed, May 5, 2010 at 3:18 PM, Meikel Brandmeyer wrote: > Hi, > > On Wed, May 05, 2010 at 02:56:09PM -0700, gary ng wrote: > Right now, this can be handled as: > > (ns foo > (:refer-clojure :as core :exclude (+))) > > (defn + > [matrix1 matrix2] > ... (co

Re: last-var-wins: a simple way to ease upgrade pain

2010-05-05 Thread gary ng
On Wed, May 5, 2010 at 10:34 PM, Meikel Brandmeyer wrote: > I'm deeply suspicious of such a behaviour. Why would + on a > date mean adding days? Why not hours? minutes? seconds? > months? years? I would always prefer plus-days over such a > behaviour, because I wouldn't have to think everytime, w

Re: Restricted eval

2010-05-06 Thread gary ng
On Thu, May 6, 2010 at 4:19 AM, Mibu wrote: > As far as I can tell, clj-sandbox works by a set whitelist of > arbitrary functions, which is not a very generic approach. It works > for sandboxes like clojurebot, but not for other stuff. > > A restricted eval in all likelihood will not refer direct

Re: Restricted eval

2010-05-06 Thread gary ng
On Thu, May 6, 2010 at 10:49 AM, Heinz N. Gies wrote: > If I may :) since I'm the sandbox guy. > > Is it possible to use the sandbox functionalities without the future/thread part ? Basically, I am trying to create a chatty REPL(say HTTP POST based). the thread would be created by the app conta

Re: Easier way to run Clojure from command line?

2010-05-08 Thread gary ng
On Sat, May 8, 2010 at 9:20 AM, Adam Jones wrote: > Have you seen Leiningen? [1]. It seems like it will do what you want > with "lein repl", and additionally it has some nice features for > acquiring dependencies and building a .jar from your project. > > [1] http://github.com/technomancy/leining

Re: code review:replace-first

2010-05-08 Thread gary ng
I would use reductions(i.e. Haskell's scanl) given my understanding that clojure sequence is just as lazy as Haskell. (rest (map first (reductions (fn [ [v a b] x ] (if (= a x) [b nil b] [x a b])) [nil 2 3] '(1 1 2 2 3 4 I use nil here as 'something that would not appear in the list', I am su

Re: code review:replace-first

2010-05-08 Thread gary ng
On Sat, May 8, 2010 at 1:01 PM, Meikel Brandmeyer wrote: > Hi, > > if you want to go low-level you can use lazy-seq. > > (defn replace-first > [needle replacement coll] > (lazy-seq >(when-let [s (seq coll)] > (let [fst (first s)] >(if (= fst needle) > (cons replacement

Re: Easier way to run Clojure from command line?

2010-05-08 Thread gary ng
> > Unfortunately lein repl is apparently broken on windows. > > Works for me. Microsoft Windows [Version 6.0.6002] Copyright (c) 2006 Microsoft Corporation. All rights reserved. C:\Users\gary>lein repl Clojure 1.1.0 user=> quit java.lang.Exception: Unable to resolve symbol: quit in th

Re: asm-based clojure yet?

2013-05-17 Thread Gary Trakhman
I think these qualify as low-footprint clojures: https://github.com/clojure/clojurescript on node.. https://github.com/takeoutweight/clojure-scheme compiles to native https://github.com/halgari/mjolnir llvm targets. On Fri, May 17, 2013 at 7:10 AM, atkaaz wrote: > Ok, weird question: is there

Re: asm-based clojure yet?

2013-05-18 Thread Gary Trakhman
Immutability, persistence, closures without a serious garbage collector sounds hard. On Sat, May 18, 2013 at 1:09 AM, atkaaz wrote: > Thanks very much everyone! I'm looking into all of those, but currently > planning to read Julian's pdf. I didn't want to say anything until I had > something de

Re: asm-based clojure yet?

2013-05-18 Thread Gary Trakhman
atkaaz wrote: > your comment caused me to be reading this > http://prog21.dadgum.com/134.html > (at least) > > > On Sat, May 18, 2013 at 6:17 PM, Gary Trakhman wrote: > >> Immutability, persistence, closures without a serious garbage collector >> sounds hard. &

Re: More idiomatic way to find the first non-nil function result?

2013-05-20 Thread Gary Trakhman
boolean algebra... demorgan's laws.. etc.. http://en.wikipedia.org/wiki/De_Morgan's_laws On Mon, May 20, 2013 at 1:38 PM, Jeb wrote: > Is there a term/phrase that describes this style of programming (as > opposed to nested ifs, for example)? > > > On Wednesday, May 1, 2013 12:46:36 PM UTC-5, Ce

Re: Design/structure for a game loop in clojure

2013-05-20 Thread Gary Trakhman
I thought this approach was interesting: http://www.chris-granger.com/2012/12/11/anatomy-of-a-knockout/ A key insight I've seen promoted in other places is to use flattened structures and identities instead of nested object hierarchies, thus your handy sub-lists may be represented as graph queries

Re: Stackoverflow on a function listing files in a directory recursively

2013-05-20 Thread Gary Trakhman
Is this not sufficient? file-seq https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4478 On Mon, May 20, 2013 at 4:28 PM, Jim - FooBar(); wrote: > have you considered using mapcat recursively? something like this > perhaps? > > (defn list-all-files [^java.io.File dir] >

Re: Stackoverflow on a function listing files in a directory recursively

2013-05-20 Thread Gary Trakhman
. > > Jim > > > On 20/05/13 21:39, Jim - FooBar(); wrote: > > actually yes it is! :) I thought file-seq was going down one level only > but looking at the implementation it seems it goes down all levels...I'm > trying it out now > > Jim > > On 20/05/13

Re: Stackoverflow on a function listing files in a directory recursively

2013-05-20 Thread Gary Trakhman
Ramesh, I think the main problem is you're trying to do a recursion over a tree, so you're blowing a stack if you're not careful, concat is lazy so I think you're just shifting the problem around, file-seq gets around this by using tree-seq, which uses 'walk', which is a linearization of the tree.

Re: asm-based clojure yet?

2013-05-22 Thread Gary Trakhman
emacs does this navigation stuff.. M-. and M-, . For uses of a function, try grep -R or rgrep. On Wed, May 22, 2013 at 1:30 PM, atkaaz wrote: > Looks like I forgot to enable the paging file (windows virtual memory was > disabled) and that is why my eclipse/firefox would crash when running out >

Re: How to: reduce boolean operations?

2013-05-23 Thread Gary Trakhman
A while back I saw some java slides that elude me now, they mentioned approaches to safety like defensive copying, immutability, etc.. their conclusion at the end, that I seem to remember, was it only really made sense to validate user input, a sort of wall, where anything past the wall is assumed

Re: Future/Promise and not using threads

2013-05-30 Thread Gary Trakhman
Maybe an easy solution: wrap the first future in another future that blocking-derefs, then performs your extra computation? Do an extra 'realized?' check for the optimization you mention. That would still consume threads in the case that it's not realized, but I think it gets you what you want.

Re: Future/Promise and not using threads

2013-05-30 Thread Gary Trakhman
e of these that uses the unbounded agent thread-pool, but you would be free to return one using reify or something. https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L6320 On Thu, May 30, 2013 at 5:14 AM, Gary Trakhman wrote: > Maybe an easy solution: wrap the first f

Re: What is the status of Clojure on LLVM or C?

2013-05-30 Thread Gary Trakhman
I just thought about this recently, but does the value-oriented nature of clojure mostly void the need for a cycles-aware GC? It seems like you won't ever have cycles without identities, or pointers (java references). Maybe this would be a problem only when you need identities, ie deftype or defp

Re: What is the status of Clojure on LLVM or C?

2013-05-30 Thread Gary Trakhman
7;orange wrote: > > > On Thursday, May 30, 2013 2:21:36 PM UTC+2, Gary Trakhman wrote: >> >> I just thought about this recently, but does the value-oriented nature of >> clojure mostly void the need for a cycles-aware GC? It seems like you >> won't ever have cy

Re: What is the status of Clojure on LLVM or C?

2013-05-30 Thread Gary Trakhman
(atomic inc & dec). So if you have two > cores reading (not just writing) from the same hash-map, they'll be > fighting over the cache lines that the refcount is stored in, and that'll > kill performance. > > Timothy > > > On Thu, May 30, 2013 at 8:47 AM, Gary Tr

Re: Use of io!

2013-05-30 Thread Gary Trakhman
What if you really want the 'bad' effects on retries? We need io! versions and non-io! versions of side-effect functions :-) On Thu, May 30, 2013 at 1:24 PM, Sean Corfield wrote: > On Thu, May 30, 2013 at 1:10 AM, Alex Baranosky > wrote: > > Do any of you ever use io! ? I've never used it, bu

Re: Use of io!

2013-05-30 Thread Gary Trakhman
Well, more seriously, I would be against any facility that prevents me from doing something potentially useful that I might want to do. Sprinkling potential problem spots with io! might make more sense in an application than a library. On Thu, May 30, 2013 at 1:27 PM, Gary Trakhman wrote

Re: What is the status of Clojure on LLVM or C?

2013-05-30 Thread Gary Trakhman
ts. Consider multi-core, now the >> refcounts have to be thread safe (atomic inc & dec). So if you have two >> cores reading (not just writing) from the same hash-map, they'll be >> fighting over the cache lines that the refcount is stored in, and that'll >> kill

Re: What is the status of Clojure on LLVM or C?

2013-05-30 Thread Gary Trakhman
>>> to increment and decrement the refcounts. Consider multi-core, now the >>> refcounts have to be thread safe (atomic inc & dec). So if you have two >>> cores reading (not just writing) from the same hash-map, they'll be >>> fighting over the cache lines that the

Re: Idiomatic way to write dependency resolving algorithms?

2013-05-31 Thread Gary Trakhman
You can express the algorithm using reduce with the set as an accumulator. Also, consider: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L4969 and related hierarchy functions. On Fri, May 31, 2013 at 12:33 PM, Alice wrote: > (def graph > {"a" {:dependencies ["b" "

Re: Best IDE

2013-06-04 Thread Gary Trakhman
I used eclipse emacs+ for about a year for java code once I had started writing clojure in emacs, it made me more productive, but it was a hassle to set up. Unfortunately, when eclipse updated itself to juno, it broke, and there is still no support. Going forward, I think this is a more compellin

Re: WSS Clojure client

2013-06-04 Thread Gary Trakhman
nginx is a web server, and I don't think what you want. You probably want to use apache httpclient or a wrapper library. I hate all the wrapper libraries, and I've used clj-http and clj-apache-https. A quick google search turns up an alternative, seems promising: https://github.com/victor-github

Re: WSS Clojure client

2013-06-04 Thread Gary Trakhman
egant, but it's likely less tested than the java libs. I guess I'll change my answer to, 'it depends'. :-) On Tue, Jun 4, 2013 at 3:13 PM, Michael Klishin wrote: > 2013/6/4 Gary Trakhman > >> I hate all the wrapper libraries, and I've used clj-http and >>

Re: [ANN] alpacas: a new Clojure source viewer

2013-06-04 Thread Gary Trakhman
Just fyi, most clojure libs are published under EPL or Apache licenses, of course the choice is up to you :-). GPL has some restrictions that would prevent the lib from being used in many projects. from the EPL wikipedia page: 'The EPL 1.0 is not compatible

Re: importing a java class which 'requires' your namespace in a static block

2013-06-05 Thread Gary Trakhman
One problem with doing this in a static initializer is that you lose the relevant exception. I would try moving this to a constructor or lazy-load it, and you might get a better error message. On Wed, Jun 5, 2013 at 1:28 PM, Jim - FooBar(); wrote: > Hello everyone, > > weirdness strikes again!

Re: Making things go faster

2013-06-06 Thread Gary Trakhman
> Note that the problem is actually the Clojure startup time, *not* the JVM > startup. JVM starts up in about 0.1sec on my machine. The rest of the time > is spend loading Clojure code, compiling all the core namespaces etc. > > That's one way to look at it, another is that clojure's design tightly

Re: How to cleanly interface with a Java lib that requires mutability?

2013-06-07 Thread Gary Trakhman
sounds fun, have you seen this yet? http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ On Fri, Jun 7, 2013 at 3:21 PM, Denis Labaye wrote: > Hi, > > I'm writting Clojure code that is used by a Java framework (Fitnesse's > slim for those who knows). >

Re: Reflective method invocation

2013-06-11 Thread Gary Trakhman
The result can be JVM-dependent. I've solved a bug in our codebase that was due to JDK 7's reflection preferring a different constructor for an object than 6, which was fixed by explicitly wrapping the ambiguous argument in (boolean). Whatever the behavior, it's best to not rely on a specific bro

Re: [pre-ANN] test2, the last Clojure testing framework

2013-06-11 Thread Gary Trakhman
2 cents, I don't see the value in mixing and matching lower-level constructs between test frameworks, which also sounds hard. I see a lot of value in what the SPEC provides, standardized test-reporting, metadata and runner infra. This makes tooling's life easier, and would ease the burden of using

Re: In what OS do you code?

2013-06-14 Thread Gary Trakhman
Linux. I started making the investment 12 years ago with RedHat 6.2 and Slackware, so the extra fuss-time tradeoff is worth it for me, since I can minimize it by now. I can have a working clojure system from scratch in 20 minutes, which I've demonstrated here: http://gtrak.wordpress.com/2012/12/1

Re: In what OS do you code?

2013-06-14 Thread Gary Trakhman
Yes, I installed the OS, too, that includes emacs, auto-complete, ac-nrepl (I had some problem and had to look stuff up, I can do it faster now). On Fri, Jun 14, 2013 at 9:54 AM, Denis Labaye wrote: > > > > On Fri, Jun 14, 2013 at 3:52 PM, Gary Trakhman wrote: > >> Linux.

Re: A* Graphe implementation

2013-06-16 Thread Gary Trakhman
What do you need to do, more specifically? For a basic clojure introduction, check out: http://dev.clojure.org/display/doc/Getting+Started On Sun, Jun 16, 2013 at 5:42 PM, Clojurist wrote: > Hey everyone, I'm having a project where i have to create an app for A* > algorithm, and the thing is t

Re: Need to render some entities moving across a grid

2013-06-17 Thread Gary Trakhman
For something quick and dirty, have you taken a look at quil? It's pretty easy to get started. https://github.com/quil/quil On Monday, June 17, 2013, vemv wrote: > I'm implementing a program D. Hofstadter describes in *Fluid Concepts: * > https://github.com/vemv/jumbo/* *Even in the original t

Re: First day with Macros

2013-06-17 Thread Gary Trakhman
Unquoting 'camel-case-method-name' is going to try and replace the symbol with it's value during compile-time in the context of the macro itself. also, reify isn't going to work if you need a named class to actually wire up your servlet, for example with a web.xml. Also, consider that you'll need

Re: First day with Macros

2013-06-17 Thread Gary Trakhman
; (for [meth ~meths] >(let [[method-name args & body] ~meth > camel-case-method-name (hyphenated->camel-case ~method-name)] > (camel-case-method-name ~args ~@body) > > Still it is not working :( > > How to fix it? > > On Tue

Re: What the recommended way now to create an instance and override its methods?

2013-06-18 Thread Gary Trakhman
I think you need to read something comprehensive before any of these replies start to make sense, I would recommend Joy Of Clojure, or some good blog posts. This might be a good starting point with some links for further reading: http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/ To un

Re: First day with Macros

2013-06-18 Thread Gary Trakhman
> backtick at the beginning and then we use ~ and ~@ when needed. > > > On Tuesday, June 18, 2013 2:09:44 AM UTC+2, Carlo wrote: > >> I can't speak to the issues that Gary raised, but I can help you with >> your macro. >> >> (defmacro servlet [servlet

Re: Need to render some entities moving across a grid

2013-06-18 Thread Gary Johnson
vious what to comment out of the with-animation macro. Good luck and happy hacking, ~Gary On Monday, June 17, 2013 3:17:01 AM UTC-4, vemv wrote: > > I'm implementing a program D. Hofstadter describes in *Fluid Concepts: * > https://github.com/vemv/jumbo/* *Even in the original t

Re: Best practice for looping

2013-06-22 Thread Gary Trakhman
Do you have the stack trace? It's not simple to run the code, but I made a github project so we can look at it easier. https://github.com/gtrak/grad-descent-test When I run (gradient-descent example-grad [0 1] 0.001 0.001) Here's the actual problem: grad-descent.core> (pst *e) StackOverflowError

Re: Best practice for looping

2013-06-22 Thread Gary Trakhman
LazySeq.java:42) clojure.lang.LazySeq.seq (LazySeq.java:60) clojure.lang.RT.seq (RT.java:473) clojure.core/seq (core.clj:133) clojure.core/map/fn--4087 (core.clj:2426) nil user> On Sat, Jun 22, 2013 at 1:10 PM, Gary Trakhman wrote: > Do you have the stack trace? It's not simple to

Re: what execurtes what in clojure

2013-06-22 Thread Gary Trakhman
Check out https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L404 and https://github.com/clojure/clojure/blob/master/src/jvm/clojure/main.java On Sat, Jun 22, 2013 at 7:20 PM, jayvandal wrote: > in a project file the > :main my-website.server) > Is this like a go to statem

Re: Packaging data_readers.clj with a Clojar

2013-06-22 Thread Gary Trakhman
I don't think there's a way to make aliases for reader literals, which you would want in order to avoid breaking this rule: "Reader tags without namespace qualifiers are reserved for Clojure." from http://clojure.org/reader#The Reader--Tagged Literals But I haven't tried it myself, is that the cas

Re: Best practice for looping

2013-06-24 Thread Gary Trakhman
pst is printstacktrace, it's in the clojure.repl namespace and comes with clojure. Sometimes lein or something makes it available automatically, but if it isn't, you can (use 'clojure.repl) to get to it. http://clojure.github.io/clojure/clojure.repl-api.html#clojure.repl/pst Yes, switching to ma

Re: matching, assigning and branching in one form

2013-06-24 Thread Gary Johnson
-find #"^:(.*?)!.*PRIVMSG (.*) :(.*)" msg)] (true-branch) (false-branch)) If you use an expression that returns a sequence with if-let, just wrap it in a call to seq, like so: (if-let [[a b c d] (seq (filter anything-good? some-coll))] (true-branch) (false-branch)) Happy hacki

Re: Pure/deterministic functions, as values in the compiler

2013-06-26 Thread Gary Trakhman
The first thing I think of along these lines is codeq http://blog.datomic.com/2012/10/codeq.html When I first heard about it, I thought it might have potential for code reuse and whole-program optimization. If you've ever imported something that causes irrelevant classes to take up space in your

Re: I'm starting to wonder if I'm the only person using clooj ...

2013-06-28 Thread Gary Trakhman
I wanted to try out 0.4.1 on my desktop, is there a trick to getting it to run on windows? It errored out with something that looked like OSX-specific AWT usage. I can look at it more deeply some time. On Fri, Jun 28, 2013 at 10:06 AM, Lee Spector wrote: > > On Jun 28, 2013, at 4:53 AM, Rich M

Re: I'm starting to wonder if I'm the only person using clooj ...

2013-06-28 Thread Gary Trakhman
Happens on linux too: gary@gary-dell:~/dev$ java -jar ~/Downloads/clooj-0.4.1-standalone.jar # java.lang.ClassNotFoundException: com.apple.eawt.FullScreenUtilities at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355

Re: Sharing result of macro's calculation with the body

2013-07-01 Thread Gary Trakhman
Whenever I make a macro like this, I pass the symbol to be captured as an argument to the macro. Any collisions would be more explicit and less surprising. On Mon, Jul 1, 2013 at 11:21 AM, Baishampayan Ghose wrote: > Hi, > > What you need is called an anaphoric macro (via symbol capture). > Clo

Re: Web crawling tree traversal

2013-07-05 Thread Gary Trakhman
I wrote this a while ago, here it is :-) https://github.com/gtrak/betamore-clj/blob/master/src/betamore_clj/core.clj On Thu, Jul 4, 2013 at 1:23 PM, Amir Fouladi wrote: > Hi everybody > > I'm a clojure newbie, so I'm sorry if I'm asking a dumb question. > I'm trying to write a program to crawl

Re: Can't figure out how to merge this dern map.

2013-07-08 Thread Gary Trakhman
I think the destructuring you're trying to do uses [ ]. Apply/reduce merge is the general answer. On Mon, Jul 8, 2013 at 11:16 AM, Alexander Solovyov wrote: > The simplest way I see is > > (apply merge (filter identity '({:apple "red and crunchy"} nil nil {:Numb > 1} nil nil {:Field "FRUIT.Desc

Re: Can't figure out how to merge this dern map.

2013-07-08 Thread Gary Trakhman
Into is reduce-conj, and this relies on a special-case of conj for maps and map entries. I find it hard to read, so I would vote for apply/reduce merge. This is weird and unexpected, so please don't: user> (into {:c :d} [{:a :b}]) {:c :d, :a :b} user> (into {:c :d} {:a :b}) {:c :d, :a :b} On M

Re: Confused about exception handling

2013-07-08 Thread Gary Trakhman
Clojure doesn't have checked exceptions, but it uses a java compiler trick called sneaky-throws to rethrow and catch them, so versions past 1.3 don't wrap them in RuntimeExceptions. Generally, clojure won't go out of its way to protect you from exceptions or catch them for you, but it's idiomatic

Re: Clojure: Elegance vs. Performance?

2013-07-09 Thread Gary Trakhman
The TCO macro already exists: https://github.com/cjfrisz/clojure-tco On Tue, Jul 9, 2013 at 1:39 PM, Ben Wolfson wrote: > On Tue, Jul 9, 2013 at 10:28 AM, Mikera wrote: > >> >> A reasonably simple optimisation would be to automatically identify >> self-recursion in tail position and convert it

Re: ClassCastException in APersistentVector.doEquiv with custom implementation of IPersistentVector

2013-07-09 Thread Gary Trakhman
>From the lack of extending java's Collection in IPersistentVector or associated interfaces, it seems like the intent is for every implementation to extend (proxy) APersistentVector. Is that sufficient for what you're trying to do? None of the methods in there are final. On Tue, Jul 9, 2013 at

Re: clojure interpreters?

2013-07-09 Thread Gary Trakhman
An issue with an interpreter is keeping semantics in sync with canonical clojure. Unfortunately, since 'Clojure' is a superset of java's semantics, it's possible to have different behavior with regards to classloading and such. Environment-as-a-value means decoupling vars and such from being globa

Re: test run startup time

2013-07-10 Thread Gary Trakhman
Real work is done with a repl embedded into a text editor with live eval. Running tests is just a function call away, clojure.test/run-tests. Here's a modern starting point: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded On Wed, Jul 10, 2013 at 1:36 PM, Brian Craft wrote:

Re: ClassCastException in APersistentVector.doEquiv with custom implementation of IPersistentVector

2013-07-10 Thread Gary Trakhman
in the present case that's >> fine? >> >> I'm just remembering that Collection is an interface and not a class, so >> I guess that's not too bad since I can add it to my reify. >> >> [1] http://clojure.org/datatypes >> >> Than

Re: Clojure: One language to rule the Web

2013-07-11 Thread Gary Trakhman
It's true that many of these systems are equivalently powerful and redundant, but the dominant forces driving them are social, not technical. Fred Brooks's 'The Mythical Man-Month' is the classic book on this topic. In an ideal world, where information flowed freely and instantly, all these menti

Re: --> macro proposal

2013-07-16 Thread Gary Johnson
Ugh. What a pointless thread. Someone could have just said: --- It's already in clojure 1.5. The form you are looking for is called as->. Your original example would be written like this: (as-> 3 x (+ 1 x 4) (prn "answer:" x)) --- Done. Yeesh. On Sunday, July 14, 2013 12:34:02 PM UTC-4,

Re: Performance Patterns

2013-07-17 Thread Gary Trakhman
I have a variant of the timings macro that I used to profile some numeric code recently. You sprinkle it in your code, and it aggregates timings during a run by keywords of your choice.: (def ^:dynamic *times* nil) (defmacro timek "Evaluates expr and prints the time it took. Returns the va

Re: Interest in a Full Featured Clojure Blog Engine

2013-07-18 Thread Gary Trakhman
Django's pretty good at this with it's auto-gen'd Admin interface, if we had something comparable it would be compelling to a large audience, but I worry that it becomes 'frameworky' at a certain point, and clojure has a bias against that. On Thu, Jul 18, 2013 at 11:10 AM, Timothy Washington wrot

Re: ns defaults

2013-07-18 Thread Gary Trakhman
Could you abuse a reader literal? Seems like it could work at first glance. On Thu, Jul 18, 2013 at 4:34 AM, Jozef Wagner wrote: > Compiler loads and refers clojure.core namespace for each new namespace. In > my projects, I often have one or two namespaces I use nearly in every other > namespac

Re: separate namespace for extra-special forms?

2013-07-20 Thread Gary Verhaegen
fn and let are macros in the clojure.core namespace; & is technically not a valid character in a symbol, but the Clojure reader is quite lenient on that front. As far as I know, it is not treated as anything special at the level of the language, it is just interpreted by the destructuring macros.

Re: Robo VM

2013-07-22 Thread Gary Trakhman
Seems like it would need reflection and classloaders for loading ASM bytecode, and the run-time would thus need its compiler, I can't tell from the site whether that's the case. If there's no reflection, then it would be a pain to make clojure work. But, I see it says: 'The standard classes (java

Type hint puzzler

2013-07-22 Thread Gary Fredericks
Can anybody figure out how I can type hint this adequately? Not only does it result in reflection, but because a Fn is both a Runnable and Callable, it can result in runtime incorrectness: https://gist.github.com/fredericksgary/6058783 -- Gary Fredericks (803)-295-0195 fredericksg...@gmail.com

Re: Can we please deprecate the :use directive ?

2013-07-23 Thread Gary Trakhman
We should scour clojuresphere for uses of 'use' and automatically post github issues to the projects of interest, and redefine the ns macro to issue a warning with use. Does anyone actually like 'use'? Require is always more evident. On Tue, Jul 23, 2013 at 2:17 PM, Jozef Wagner wrote: > +1, :

Re: Can we please deprecate the :use directive ?

2013-07-23 Thread Gary Trakhman
ote: > For much the same reason, I've been using :require with :as and a > one-or-two-letter alias, so I can do x/whatever. Generally works well. > > > On Tue, Jul 23, 2013 at 1:38 PM, Lee Spector wrote: > >> >> On Jul 23, 2013, at 2:27 PM, Gary Trakhman wrote:

Re: Can we please deprecate the :use directive ?

2013-07-23 Thread Gary Trakhman
short alias >> seems a better approach for teaching / explaining things but I'm sure >> I'm guilty of :use in earlier blog posts about Clojure (... checking >> ... yup, three blog posts from early 2012 contain :use, mostly with >> :only, so those should be updated to use

Re: Can we please deprecate the :use directive ?

2013-07-23 Thread Gary Trakhman
ersely proportional to its effect, so it takes extra effort to limit its effects. A limited scope by default is what I mean by 'good', for similar reasons that clojure goes with 'immutability by default'. On Tue, Jul 23, 2013 at 3:57 PM, Lee Spector wrote: > > On Jul 23

Re: Can we please deprecate the :use directive ?

2013-07-25 Thread Gary Trakhman
You could also do (use 'clojure.test) below the ns form. One thing that generally annoys me with 'ns' is that people feel it's some magical thing that has to be in the head of every file, like java imports, but it's really just a macro. It just goes to show that conventions are important. Curiou

Re: map from list of maps

2013-07-25 Thread Gary Trakhman
user> (into {} (map (juxt :a :b) [{:a "blah" :b "ack"} {:a "red" :b "blue"}])) {"blah" "ack", "red" "blue"} On Thu, Jul 25, 2013 at 5:34 PM, Brian Craft wrote: > Is there a better way to do this, making a map of certain keys from a list > of maps? > > > (apply hash-map (mapcat (fn [x] [(x :a)

Re: is intellij idea a good ide for clojure development?

2013-07-25 Thread Gary Trakhman
You can pick and choose your level of bloat with emacs. It's pretty good at being a lisp editor. I don't customize mine much, been using it for a year and a half, and I was 80% as productive as I am now within just a few weeks, though I realize there's a lifetime left to learn. Starter-kit + 24-

Re: is intellij idea a good ide for clojure development?

2013-07-25 Thread Gary Trakhman
'jumping to a symbol's definition (and back again)? Those didn't seem to be there last time, and I'd struggle to live without them on a project of any size.' Besides paredit, this is absolutely the most important feature for me day-to-day. Nothing will replace emacs unless it has that. The emac

Re: How convert from string to symbol?

2013-07-25 Thread Gary Trakhman
It might be more clear if you simply show sample inputs and outputs. Something like this: in: "name" out: 'name probably what you want is: (symbol (name x)) works for keywords too, cuts off any namespace prefix. On Thu, Jul 25, 2013 at 9:29 PM, wrote: > Hello, > I have a problem how we

  1   2   3   4   5   6   7   8   9   >