Re: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)

2013-11-22 Thread Armando Blancas
We use select several times in one module; it wouldn't be hard to just copy and paste the function somewhere. Now, you could drop DSL and call it optional utility functions not to be used when deemed unhelpful, or whatever. Given your goals stated goals that code isn't bad at all. On

Re: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)

2013-11-22 Thread Armando Blancas
Didn't think of that. I can just rewrite those simple select calls with parameterized raw SQL, which is our preferred way of using the API. On Friday, November 22, 2013 2:09:19 PM UTC-8, Sean Corfield wrote: On Fri, Nov 22, 2013 at 1:04 PM, Armando Blancas abm2...@gmail.comjavascript

Re: bug in clojure.zip when calling next on empty list node?

2013-12-31 Thread Armando Blancas
The implementation of seq-zip uses seq? as its branching predicate. As a result the zipper goes down on () thinking it can have children: user= (seq? ()) true user= (seq? {}) false user= (seq? #{}) false user= (seq? []) false On Sunday, December 29, 2013 10:14:23 AM UTC-8, Lee wrote: I

Re: unconditional append to end

2014-02-07 Thread Armando Blancas
For efficient appends at the end you need a vector. Using the sequence library can be tricky while you're putting together your data structures because it's likely that you'll not done yet with type-specific functions. You'll need to re-create your vector after using map/filter/etc to be able

Re: Can't start repl with Leiningen

2014-02-26 Thread Armando Blancas
I had the same problem with an old box I had around the house. Put Fedora 20 on it with a recent open jdk, but had just 1GB of memory total. I attributed the error to the lower memory since I never have that issue at work or other machines with at least 4GB. If you have more than 2GB,

Re: What is the right way to create dynamic var in another namespace?

2014-03-01 Thread Armando Blancas
This came up a while back and it appeared that the metadata just reflected whether the var was created with the ^:dynamic annotation. But the meta attribute is an output, so to speak; the info flows from the var declaration to the meta but not the reverse. Maybe it'll remain like that as

Re: creating a map

2014-03-27 Thread Armando Blancas
To add a little, into is generic and has no special treatment if the collection is a map, but works with maps if the elements are vectors because map associations of key-value pairs are a subclass of vector. The other way around: user= (for [elem {:foo :bar}] elem) ([:foo :bar]) ; extracts :foo

clojure-jsr223

2009-11-20 Thread Armando Blancas
Without knowing of Niels Mayer's work (until just now) I wrote an implementation of the Java Scripting API for Clojure --and even named it the same. Indeed great minds think alike. Though I didn't think of isolating the runtime in different instances of the engine. The distribution ZIP file has

Re: Clojure Scoping Rules

2009-11-21 Thread Armando Blancas
I sympathize with your difficulties, but isn't there something fundamentally incompatible between the later-or-never of lazy-seq and the this-way-here-and-now for which dynamic binding is good for? In this case you picked laziness over code simplification, maybe it'll be the other way around some

Re: Improving Clojure startup time with -Xbootclasspath

2009-11-23 Thread Armando Blancas
I added the contrib lib expecting it to fail but it worked, and loaded (in half the usual time) some code from the user.clj as well: java -Xbootclasspath/a:clojure\clojure.jar;clojure-contrib\clojure-contrib.jar clojure.main Clojure 1.1.0-alpha-SNAPSHOT user= I had been reading in this paper:

Re: Some basic guidance to designing functional vs. state parts of app

2010-03-03 Thread Armando Blancas
On Mar 2, 8:34 pm, Sophie itsme...@hotmail.com wrote: Do I design a single World ref whose state changes with time to different worlds, so adding a new Applicant or even adding a new Skill to an existing Applicant results in a new World value? Or is it better to have an Applicants ref and a

Re: I confused myself. How can I solve this simple problem?

2010-03-08 Thread Armando Blancas
What about coding it as a hook? Though I realize you have to introduce a new name. user= (defn myprintln [str] (println str) (println tacked on)) #'user/myprintln user= (let [print-hk myprintln] (print-hk some code)) some code tacked on nil user= (let [print-hk println] (print-hk some code))

Re: Clojure Implementation issues that may affect performance?

2010-03-09 Thread Armando Blancas
By listing the code above you've shown why the default must be so, since calling your function with any of those types will just work (at least before an stack overflow), which of course can't be done with primitive types. For an untyped language with a worry-free numeric abstraction, this seems

Re: Can't call public method of non-public class

2010-03-23 Thread Armando Blancas
You want Clojure to treat 'env' as a Map instead of its implementation class, which is not public. Just add the type hint #^Map to 'env''s def: user= (def pb (new ProcessBuilder [myCommand myArg])) #'user/pb user= (def #^Map env (.environment pb)) #'user/env user= (.put env VAR1, myValue) myValue

Re: Can't call public method of non-public class

2010-03-24 Thread Armando Blancas
You probably can't. I think hints only go in binding declarations. I'd use 'env', as you're probably doing already. But let's keep an eye on Mark's patch, as it'd be much better to avoid an explicit upcasting. On Mar 23, 7:38 pm, Konstantin Barskiy zuftw...@gmail.com wrote: Thanks a lot! Is

Re: formatting hex string

2010-03-31 Thread Armando Blancas
The full, future-proof solution is something like this: (map #(let [n (Integer/parseInt % 16)] (short (if (bit-test n 15) (bit-or n -65536) (bit-and n 65535 [ff43 0032]) (-189 50) But if numbers should default to positive but not be coerced to negative, e.g., a -189 just for (short

Re: , is REAL whitespace...

2010-04-02 Thread Armando Blancas
So, it's all some form of RTFM... but one could argue that this novel use of commas in the syntax results in adding a little incidental complexity to the language ;-) You put some pretty specific assumptions into your code: commas as separators, commas with a proper place in Clojure syntax,

Re: REPL and its command prompt

2010-04-02 Thread Armando Blancas
It's clear that a REPL used interactively must respond as it does, otherwise it's appear hanged. Do you have a particular scenario for your code? I thought about recreating or documenting a session, but you can't see the input, only the REPL's output. On Apr 2, 12:23 am, Michael Jaaka

Re: A syntax question: positional keyword

2010-04-07 Thread Armando Blancas
Just curious   - what folks think of fixed-positional-keyword params   - whether it was considered for Clojure It's difficult to image that keyword params will be considered in languages where they aren't folklore, as they are in Smalltalk, Objective-C, and Self. Unlike Smtalltalk and Self,

Re: New clojure support in Polyglot Maven

2010-04-08 Thread Armando Blancas
Looks cool. This should help the XML-allergic :) Though I don't like it, the XML is the least of my problems. Don't know what to do or even where to start. I want to do the following in maven or pmaven, but anything beyond their Hello World example has been a real struggle :-(Any pointers?

Re: New clojure support in Polyglot Maven

2010-04-08 Thread Armando Blancas
Thanks for your response. Since that's already more than I can chew I'll stick to regular pom files as I try to follow your directions and look through docs and samples. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email

Re: (- x 1) and (dec x) behave differently

2010-04-20 Thread Armando Blancas
My problem was that I thought the literal 1 will be boxed behind the scenes, I didn't even bother looking for a version of add for primitives because I thought they never existed in Clojure. I'll try to go over the Numbers class again and see if all this makes sense. Looks like the compiler

Re: Try + finally question

2010-04-23 Thread Armando Blancas
Is there any easy workaround which doesn't involve defing a global conn. To do all in a single place you'll have to mimic the Java idiom. (let [conn (atom nil)] (try (reset! conn (API/getConnection ...) ... (catch ...) (finally (if @conn (API/closeConnection @conn) As it's

Re: Any window user familiar with clojure-contrib development ?

2010-04-26 Thread Armando Blancas
I build on Windows and it's fine most of the time. I didn't deal with (1) and (2) as my initial clone was OK; I avoid (3) with - Dmaven.test.skip=true But sometimes I get these errors even though I don't change any files. I work around this by deleting the files and repeating the pull. I don't

Re: Defining a namespace inside a let

2010-04-29 Thread Armando Blancas
The REPL switches to the namespace ns-1 and the var my-namespace is in user ! I don't see that with CLJ 1.2 on Windows: user= (do (ns ns-1) (def my-namespace *ns*) my-namespace) #Namespace ns-1 ns-1= (ns user) nil user= (println (do (ns ns-1) (def my-namespace *ns*) my-namespace)) #Namespace

Re: Defining a namespace inside a let

2010-04-30 Thread Armando Blancas
describe it, the first evaluation may have created the var. Regards, alux On 29 Apr., 21:32, Armando Blancas armando_blan...@yahoo.com wrote: The REPL switches to the namespace ns-1 and the var my-namespace is in user ! I don't see that with CLJ 1.2 on Windows: user= (do (ns ns-1

Re: Interesting contrast in core

2010-05-03 Thread Armando Blancas
I'm curious why hash-map uses a form to createWithCheck, and hash-set uses a static method. They both use a static method, though hash-set uses the newer idiomatic syntax. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: Question about namespaces

2010-05-09 Thread Armando Blancas
Unfortunately, this seems to break my consumer code.  Although mylibrary can see the functions from library1 and library2, consumers of mylibrary cannot.  So I end up manually having to go to all my consumer files and changing them to: (ns a-random-file-that-consumes-my-library   (:use

Re: How to visualise relations, bahavior and so on in functional programming ?

2010-05-11 Thread Armando Blancas
Booch, Rumbaugh and Jacobson took standard practices and tweaked them to the fashion of the mid '90's, tough they acknowledge only one another and their help in the UML User Guide. We can tweaking the UML away from its OOD bias as well as going to traditional techniques as simple as flowcharts,

Re: Which GUI toolkit would you like to see wrapped in an idiomatic Clojure library?

2010-05-27 Thread Armando Blancas
Remember, the actual API won't matter - that will be completely abstracted away. So try to focus on the framework's look and feel. Thanks! -Luke SWT, because of the native look and feel. I really don't like the looks of Swing. As a user of some Swing app, I don't find solace from thinking how

Re: Clojure - Python Style suggestion

2013-02-04 Thread Armando Blancas
What do you think? I think, go right ahead and give it to them. Worst that could happen is you gain insights into language design. I'd be interested in your users' comments; what worked, what didn't. If you really believe in that idea, don't give it up before you learn something from it.

[ANN] Morph v0.1.0 Monads friends: pure functions, less boilerplate

2013-02-06 Thread Armando Blancas
Morph is a new implementation of monads based on protocols. It's intended to provide the common patterns of error-handling, short-circuit sequencing, and modeling of stateful computations in pure functions. I've tried to make this library idiomatic while keeping it close to its Haskell roots.

Re: [ANN] Morph v0.1.0 Monads friends: pure functions, less boilerplate

2013-02-06 Thread Armando Blancas
to do that kind of thing at all? - I'm curious about the Monoid protocol---I have one in babbage, and it has two more methods than yours, mempty? and value (instead of monoid-specific accessors). Why not put the accessors in the protocol? On Wed, Feb 6, 2013 at 4:06 PM, Armando Blancas abm2

Re: [ANN] Morph v0.1.0 Monads friends: pure functions, less boilerplate

2013-02-07 Thread Armando Blancas
, Armando Blancas wrote: Morph is a new implementation of monads based on protocols. It's intended to provide the common patterns of error-handling, short-circuit sequencing, and modeling of stateful computations in pure functions. I've tried to make this library idiomatic while keeping

Re: [ANN] Kern 0.5.0 -- A text-parsing library

2013-02-07 Thread Armando Blancas
On Monday, 21 January 2013 18:27:07 UTC, Armando Blancas wrote: Kern is a text-parsing library based on Parsec, the Haskell monadic combinators library. It is useful for parsing all kinds of text: data, program input, configuration files, DSLs, or a full-blown programming language. My main

Re: pr-str captures stdout- Is this intentional or a bug?

2013-02-09 Thread Armando Blancas
There's nothing wrong with pr-str. Debug output should go to stderr. user= (def k (pr-str (for [x (range 5)] (do (.println *err* x) (.println *err* nothing) x 0 nothing 1 nothing 2

Re: Easier imperative-style programming

2013-02-11 Thread Armando Blancas
Here's an example of using a state monad for updating a position. The state goes into a simple map and there's a function to add coordinates. (def init {:position [100 100] :st :st0 :keys-held #{:left}}) (defn v+ [v1 v2] (vec (map + v1 v2))) The state monad can compute a value and maintain some

Re: [ANN] clj-toml 0.2.0

2013-02-25 Thread Armando Blancas
is a TOMLhttps://github.com/mojombo/tomlparser for Clojure. It was written on top of the Kern https://github.com/blancas/kern library by Armando Blancas (kudos). TOML is a minimalistic, human-readable format that maps to a hash (like INI, but more evolved). Cheers, Luca -- -- You

ANN: Kern 0.6.1, a text-parsing library

2013-03-19 Thread Armando Blancas
I've pushed to Clojars the release 0.6.1 of Kern, a text-parsing library, with some fixes and enhancements. https://github.com/blancas/kern There's updated Codox API docs and a change log. Documentation and samples: https://github.com/blancas/kern/wiki For feedback, bug reports, etc.:

ANN: Morph 0.2.0, state+error-handling with pure functions

2013-03-20 Thread Armando Blancas
Release 0.2.0 of the Morph library comes with a couple of fixes and some enhancements: https://github.com/blancas/morph Safe error-handling with non-global, shared data is now even easier: https://github.com/blancas/morph/wiki/Simpler-State-with-Error-Handling Documentation and samples:

Re: doing a Google search from Clojure?

2013-03-22 Thread Armando Blancas
Rich, you may want to check out clojure-http-client. https://github.com/technomancy/clojure-http-client (require '[clj-http.client :as client]) (spit result.html (client/get http://www.google.com/search?q=clojure;)) On Friday, March 22, 2013 12:09:07 AM UTC-7, Rich Morin wrote: I've been

Re: doing a Google search from Clojure?

2013-03-22 Thread Armando Blancas
api, if that's helpful. No API key needed. https://github.com/flatland/lazybot/blob/develop/src/lazybot/plugins/google.clj On Friday, March 22, 2013 10:54:37 AM UTC-7, Armando Blancas wrote: Rich, you may want to check out clojure-http-client. https://github.com/technomancy/clojure-http

Re: Attempt at rethrow macro

2013-04-01 Thread Armando Blancas
Define rethrow as a function; Alf's probably right. Also, change to: ~message. user= (defn rethrow [ex-class] `(catch ~ex-class x# (throw x#))) #'user/rethrow user= user= (defmacro handle-ex [message body] `(try ~@body ~(rethrow IllegalArgumentException) (catch Exception x# (throw

ANN: Eisen, a language and API for programmable apps

2013-04-05 Thread Armando Blancas
The goal of this project is to help you write programs that users can change and extend. Besides its practical advantages, there's something really powerful about modifying a deployed program, especially when it's done interactively. As to what language users should write in, I've come to

Re: Monads usage

2013-04-08 Thread Armando Blancas
Last week I released a project with a monadic translator that needed to: - work on sequences of expressions, arbitrarily nested - generate Clojure code or stop and report the first error - maintain a symbol table with easy access but not global state The relevant code is here:

ANN: Kern 0.7.0 text parsing lib has fixes, better performance

2013-04-15 Thread Armando Blancas
This is a much needed clean up and perf boost release. https://github.com/blancas/kern Function (parse-file) won't choke with big files, while new parsers (parse-data) and (parse-data-file) work much faster by relaxing their house-keeping for input that's expected to be alright (e.g.,

Re: ANN: Kern 0.7.0 text parsing lib has fixes, better performance

2013-04-15 Thread Armando Blancas
You're very welcome. Glad to know the lib is useful. On Monday, April 15, 2013 10:15:30 AM UTC-7, Omer Iqbal wrote: Thanks Armando! I've been using kern for a number of projects and I'm really grateful for the awesome documentation :) On Tue, Apr 16, 2013 at 12:38 AM, Armando Blancas

Re: ANN: Kern 0.7.0 text parsing lib has fixes, better performance

2013-04-16 Thread Armando Blancas
On Tuesday, April 16, 2013 4:06:51 AM UTC-7, Luca Antiga wrote: Great, I just updated clj-toml to 0.7.0 and all tests pass. Thanks Armando Very cool, Luca. I'll be looking for other ways to boost performance while keeping the purely functional design. -- -- You received this message

ANN: Morph 0.3.0, monads+functors lib gets perf boost

2013-04-16 Thread Armando Blancas
In this release the lib gets rid of reflective calls by adding type hints. https://github.com/blancas/morph I don't have any benchmarks, but in Ben's tree-numbering Morph's timing goes from ~13,700 msecs down to ~350. https://github.com/bwo/monads/wiki/Tree-numbering-benchmark Morph tries hard

Re: [ANN] Grojure, a Java/C# syntax atop Clojure using Kern

2013-04-29 Thread Armando Blancas
Nice work, Gavin. Grojure is a good example why Clojure is an excellent UNCOL for the JVM, so some of us will depend less on the ASM lib. Your parser illustrates how to use grammar actions for writing a very compact one-pass translator; pretty cool. On Sunday, April 28, 2013 9:41:00 PM UTC-7,

Re: [ANN] Grojure, a Java/C# syntax atop Clojure using Kern

2013-04-29 Thread Armando Blancas
for Kern over time. I haven't found any bugs in Kern so congratulations on that one. On Tuesday, April 30, 2013 1:42:06 AM UTC+8, Armando Blancas wrote: Nice work, Gavin. Grojure is a good example why Clojure is an excellent UNCOL for the JVM, so some of us will depend less on the ASM lib. Your

Re: More idiomatic way to use map like this?

2013-05-02 Thread Armando Blancas
This isn't idiomatic but can be useful for modeling mutable computations in pure functions: (use '[blancas.morph core monads]) (def cards [{:balance 30} {:balance 25}]) (def due 100) (run-state (mapm #(monad [due get-state app (state (min due (:balance %)))

Re: More idiomatic way to use map like this?

2013-05-03 Thread Armando Blancas
Having failed many attempts, I asked Feng Shen and he kindly told me how: copy some formatted text off a browser and simply paste it on this editor box. So I made a gist and instead of putting this link https://gist.github.com/blancas/5507033 I just pasted the text. On Friday, May 3, 2013

Re: [OT] Re: More idiomatic way to use map like this?

2013-05-03 Thread Armando Blancas
On Friday, May 3, 2013 1:15:24 PM UTC-7, Robert Pitts wrote: Armando was a good citizen and sent along a plain-text version as well – https://groups.google.com/group/clojure/msg/6aae8287bc55d436?dmode=sourceoutput=gplainnoredirect That must have been Google Groups doing the right thing...

Re: unusual question: how do you get morale?(or moral support)

2013-05-13 Thread Armando Blancas
Zack, you've probably come across this profile on Jeff Hammerbacher, but just in case. The best minds of my generation are thinking about how to make people click ads, he says. That sucks. http://www.businessweek.com/printer/articles/55578-this-tech-bubble-is-different On Monday, May 13, 2013

Re: Why is using (not (empty? coll)) not idiomatic?

2013-05-27 Thread Armando Blancas
There is no one who understands `(if (seq thing)` who wouldn't understand `(if (not (empty? thing))` or, better, `(if (not-empty? thing)`. The converse is not true. That suggests that the latter should be the idiom No, it doesn't. That simply illustrates that idioms must be learned, as in

Re: One name space / Multiple Modules

2011-08-05 Thread Armando Blancas
You can see a concrete example of Meikel's answer right there in the Clojure sources: files core.clj, core_deftype.clj, core_print.clj, and core_proxy.clj define the clojure.core namespace. On Aug 5, 4:57 am, octopusgrabbus octopusgrab...@gmail.com wrote: Sure. module = .clj file On Aug 5,

Re: rebind var for all threads

2011-08-11 Thread Armando Blancas
My code calls a function in 3rd party library A, which in turn calls a function in 3rd party library B.  The lib B function uses blacklisted Java classes, causing my app to crash when lib A calls it.  I would like to replace that function with a safe version, so that lib A is forced to use

Re: Small bug in clojure.core/bases?

2011-08-15 Thread Armando Blancas
I think a function should generally return the same types for different input. A seq and a Java array are two very different things even though Clojure often lets us pass both to the same functions. It seemed like a small fix, but I guess not everyone agrees. That's clearly a bug; they forgot

Re: Spitting out a lazy seq to file???

2011-08-16 Thread Armando Blancas
You can put the line break back into each line ( added stuff\n) and then do: (spit output.txt (reduce str (map change-line old-data))) On Aug 16, 8:26 am, Thomas th.vanderv...@gmail.com wrote: Hi everyone, I have been struggling with this, hopefully, simple problem now for quite sometime,

Re: I/O

2011-08-25 Thread Armando Blancas
I think part of the reason for this is the conception (maybe misconception) that most people are familiar with java and since there is java interopt they should be able to figure this out.  As more and more schools are starting to use Python as their beginning CS language, this may well not

Re: Clojure 1.3 Beta 2

2011-08-29 Thread Armando Blancas
The change to beta2 isn't working for me: dependency groupIdorg.clojure/groupId artifactIdclojure/artifactId version1.3.0-beta2/version /dependency 1.3.0-beta1 works fine. On Aug 29, 7:28 am, Christopher Redinger redin...@gmail.com wrote: Clojure 1.3 Beta 2 is now

Re: Clojure 1.3 Beta 2

2011-08-29 Thread Armando Blancas
False alarm. Some trouble with the VPN line. On Aug 29, 9:06 pm, Armando Blancas armando_blan...@yahoo.com wrote: The change to beta2 isn't working for me:     dependency       groupIdorg.clojure/groupId       artifactIdclojure/artifactId       version1.3.0-beta2/version     /dependency

Re: A re look at re-groups

2011-08-30 Thread Armando Blancas
It seems like the loop/recur is non-idiomatic for this usage and could be done with either a map or reduce. It could be that it's faster that way. How does you code perform? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send

Re: lambda function returning a constant?

2011-09-06 Thread Armando Blancas
(#(true)), is this not calling a function that has no arguments and returns true? But it still gives same exception Not really: user= (macroexpand-1 '#(true)) (fn* [] (true)) I guess I should forgo the macro and go directly with (fn  [] true) For something like = true try: user= (defmacro =

Re: Migration to 1.3 for mortals

2011-09-08 Thread Armando Blancas
There's this page: http://dev.clojure.org/display/doc/Clojure+Contrib Here's the main page for the new repos: https://github.com/clojure On Sep 7, 5:44 am, Jan Rychter jrych...@gmail.com wrote: How do we mere mortals (that develop and maintain large apps) migrate to 1.3? I thought I'd be

Re: Is there a reason that def- isn't part of the core lib?

2011-09-17 Thread Armando Blancas
There are other nine defs in core that don't have a dash version, either. I guess if they were to take def- they'd have to add the others and then add any new defs in pairs. But there's no reason to write ugly code; just write your own or use a contrib, if available. On Sep 17, 7:54 am, Rob Lally

Re: Clojure embedded in a Java Application

2011-09-19 Thread Armando Blancas
You can also do it the other way around, use gen-class and write yourself a static entry point callable from Java. That's the right way to do it, IMO. Better yet, write a Java wrapper to offer Javadocs and to hide any interop code. That means extra work on both ends, but in Java shops

Re: defprotocol problem in 1.3?

2011-10-05 Thread Armando Blancas
I'd recommend that you file a bug; surely that's a regression. As you pointed out, this fails: user= (defprotocol xyz) CompilerException java.lang.UnsupportedOperationException: Unknown Collection type, compiling:(NO_SOURCE_PATH:1) But the expansion works if you evaluate it directly, which might

Re: Should intern obey :dynamic?

2011-10-12 Thread Armando Blancas
The metadata tells you why:     user= (meta #'*dynamo*)     {:ns #Namespace user, :name *dynamo*, :dynamic true, :line 1, :file ...} The var tells you why: user= (.isDynamic (var *dynamo*)) true Now let's make another variable with `intern`, copying the metadata from `*dynamo*`:    

Re: Should intern obey :dynamic?

2011-10-12 Thread Armando Blancas
Seems to me that if you're going to use metadata to communicate intention about dynamic binding in *one* way of creating a new var, you should do it with *all* ways of creating a new var. And you may be right. My point was that a var's dynamic nature is part of its state: it's primarily

Re: SICP sqrt function generates unexpected NullPointerException

2011-10-14 Thread Armando Blancas
With 1.3/OSX this code worked up to: user= (sqrt 1) 100.0 and then hanged here: user= (sqrt 10) ~ $ On Oct 13, 7:04 pm, Alan O'Donnell alan.m.odonn...@gmail.com wrote: Hi everyone, I've encountered an unexpected NullPointerException while translating some early

Re: Rich Hickey: Simple Made Easy from Strange Loop 2011

2011-10-21 Thread Armando Blancas
(because test cases are written by the coder who has a specific intention in mind) Good observation. When I see figures of tests coverage I wonder how many flow paths aren't being covered simply because they don't exists but they should. -- You received this message because you are

Re: Clojure as scripting language in a Java Application

2011-11-03 Thread Armando Blancas
There are two libs with that name; I maintain the one in google code. In case that's the one you found, here's a status. It supports the spec, but there are two differences described in issues #4 and #5 (#3 is fixed) that arise from the spec's assumption that you'll use an interpreter. Works with

Re: clojure-jsr223 and shibboleth ScriptedAttributeDefinition

2011-11-14 Thread Armando Blancas
The compile call is a no-op and makes no difference since the engine evaluates the script. That looks like a bug in getAttribute(). I use put and get from the engine directly and may have overlooked something in the attr calls. I'll upload a fix in google code asap. On Nov 13, 9:52 am, Francesco

Re: clojure-jsr223 and shibboleth ScriptedAttributeDefinition

2011-11-14 Thread Armando Blancas
Here's a patch: http://code.google.com/p/clojure-jsr223/downloads/list Feel free to file bugs here: http://code.google.com/p/clojure-jsr223/issues/list On Nov 13, 9:52 am, Francesco francesco.m...@gmail.com wrote: I was trying to write a simple script attribute definition for shibboleth as

Re: How to deal with parameters unused by intermediate functions?

2011-12-03 Thread Armando Blancas
If foo is their only caller, bar and baz can be locals inside foo and thus giving baz direct access to foo's params. Checkout (letfn): http://clojuredocs.org/clojure_core/1.2.0/clojure.core/letfn On Dec 2, 7:34 pm, Jim Crossley j...@crossleys.org wrote: Hi, I have a public function foo that

Re: name protect anonymous macros ?

2010-12-17 Thread Armando Blancas
2. I don't want to bind the name, I want to interpret the name as a symbol user= (defmacro perpetuate [name] `(let [q# (quote ~name)] (println q#) q#)) #'user/perpetuate user= (class (perpetuate somename)) somename clojure.lang.Symbol -- You received this message because you are subscribed to

Re: Question On Implicit Recursion

2011-01-13 Thread Armando Blancas
A literal set is a unordered hash-set. To get the factors in order change #{f} for (sorted-set f). On Jan 13, 7:09 am, Vitaly Peressada vit...@ufairsoft.com wrote: The following solution by bmtgred/b for a href=http://clojure- euler.wikispaces.com/Project Euler Clojure/a problem 003 uses

Re: Enhanced Primitive Support Syntax

2011-01-14 Thread Armando Blancas
They used to give you compile switches for that kind of stuff, not hope and wholesome wishes. Seems like every performance improvements makes the language more complex, uglier or both. On Jan 14, 2:40 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: Debatable it is, endlessly. ;)  So Clojure

Re: Enhanced Primitive Support Syntax

2011-01-16 Thread Armando Blancas
Then again, how often do you write code that might be doing maths with numbers that big and not realise it?  For that matter, how often do you write code that might be doing maths with numbers that big and not spend time thinking carefully about its performance anyway? This reminds me of a

Re: Help with java conversion

2011-01-21 Thread Armando Blancas
I usually do something like this little sample. Calculations go in the let bindings and new elements are conjoined into the vector. (defn foo [n] (loop [v [] i 0] (if (= i n) v (let [x (* i i)] (recur (conj v x) (inc i)) user= (foo 6) [0 1 4 9 16 25] On Jan 21, 8:07 

Re: How does pmap partition its work?

2011-01-24 Thread Armando Blancas
This is much faster than either of the other eager-pmaps I posted to this thread, and yet it's only using 60% CPU on my dual-core box. That means there's still another x1.6 or so speedup possible(!) but I'm not sure how. Could -server make a difference here? -- You received this message

Re: What is the difference between a tail-recursive function and a recursive function using recur?

2011-01-26 Thread Armando Blancas
From SICP: With a tail-recursive implementation, iteration can be expressed using the ordinary procedure call mechanism. As I understand this, a tail call is a loop with functional notation but not actually a function call. That's why I find this issue difficult to follow, since loops are internal

Re: What is the difference between a tail-recursive function and a recursive function using recur?

2011-01-26 Thread Armando Blancas
in Clojure it will use the stack. And that's why Rich introduced clojure.core/trampoline. Cheers, -- Laurent On Jan 26, 1:10 pm, Armando Blancas armando_blan...@yahoo.com wrote: From SICP: With a tail-recursive implementation, iteration can be expressed using the ordinary

Re: java.io.IOException with compile

2011-02-02 Thread Armando Blancas
You surely mean that swing_test_listeners $some_long_function_xyx_.class is too long. On Feb 2, 6:51 am, Meikel Brandmeyer m...@kotka.de wrote: Hi, I'll just throw a wild guess into the room and say that your filename hits the filename limit imposed by the file system of your system.

Re: (identical? foo foo) evaluates to true

2011-02-15 Thread Armando Blancas
For compilation and evaluation, yes. But not strings created at rumtime like: (def foo (str \f \o \o)) http://groups.google.com/group/clojure/browse_thread/thread/e43af17a0424b1cd On Feb 15, 2:46 am, C. Arel java10c...@gmail.com wrote: Hi all, I am watching the data structure videos and there

Re: 1st script, last hurtle...

2011-02-16 Thread Armando Blancas
Looks like you could make the (println) depend directly on (re-find): (when (re-find rx line) (println line)) The check for empty line and tab might be taken care of by (re-find) to further reduce the code to something like: (when (and line (re-find rx line) (println line) (recur

Re: Release.Next Version Number

2011-02-24 Thread Armando Blancas
Without commenting on the validity of the above at all, I seem to recall that the application of the 1.0 version label prompted the same sort of concerns. You're right. No point in commenting on this whole silly thread. -- You received this message because you are subscribed to the Google

Re: easier exit

2011-02-25 Thread Armando Blancas
Using jline you can exit with ctrl-d. This is from the clojure web site in Getting Started: The REPL has very rudimentary editing. For a better experience, try running it via the JLine ConsoleRunner: java -cp jline-0_9_5.jar:clojure.jar jline.ConsoleRunner clojure.main On Feb 24, 4:38 pm,

Re: assert, illegal arguments, pre-conditions

2011-02-25 Thread Armando Blancas
I always catch Throwable at any user-facing layer, and don't catch IllegalArgumentException anywhere so it'll get caught and logged as a coding error at the top. I'm not currently using preconditions but either way will work for me. On Feb 25, 4:57 am, Shantanu Kumar kumar.shant...@gmail.com

Re: assert, illegal arguments, pre-conditions

2011-02-25 Thread Armando Blancas
IMO any decent product should at least fail gracefully and for that you must have some place at the top catching throwables, even if you can't recover. So w.r.t. the javadoc in java.lang.Error where it says [a] reasonable application should not try to catch. I interpret it as justification for the

Re: Implementing ClojureScript - command-line/sys-admin scripting with Clojure

2011-03-04 Thread Armando Blancas
Have you look at Scsh? http://www.scsh.net/about/what.html It's not the most trendy, but being a Scheme at least is nice. Anyone capable of doing the job properly either won't take any money or won't come cheap, so you might be better of offering a round of beer or request bids. On Mar 4, 1:29 

Re: Summer of Code 2011

2011-03-07 Thread Armando Blancas
You're not missing anything. In a lisp DSL, the L is a figure of speech, for it's still lisp. Sure, lisp libraries can have great ease and convenience as if they came with the language, but it won't be a different language altogether --i.e., something that it ain't lisp. Last year I wrote a little

Re: Clojure *compile-path* not set properly

2011-03-07 Thread Armando Blancas
That's the default. You'd usually use the sys env clojure.compile.path for the repl (on windows): java -Dclojure.compile.path=.;src;classes -cp clojure.jar clojure.main Clojure 1.2.0 user= *compile-path* .;src;classes On Mar 6, 5:32 pm, MC Andre andrew.penneba...@gmail.com wrote: Clojure can't

Re: Clojure *compile-path* not set properly

2011-03-07 Thread Armando Blancas
Oops -- I got the class and compile paths mixed up. But I wonder why that worked in the OP. On Mar 7, 6:27 pm, Stuart Sierra the.stuart.sie...@gmail.com wrote: The Java system property clojure.compile.path is the directory where the Clojure compiler will write out .class files.  It should be

Re: Can this function be simpler?

2011-03-10 Thread Armando Blancas
Real nice and short. Doing [ args] avoids the vector: user= (enmap 1 2 3 4 {5 6 7 8}) {1 {2 {3 {4 {5 6, 7 8} On Mar 10, 10:38 am, Takahiro fat...@googlemail.com wrote: more concise: (defn enmap [args]   (reduce #(hash-map %2 %1) (reverse args))) 2011/3/11 Takahiro

Re: setup and propagation of config-params

2011-03-10 Thread Armando Blancas
Dynamic binding is more useful when your function expect the *var* to change during the program. And sometimes you can't pass arguments through, like in (run-tests). How about a simple API with this usage: (set-opt :development) ; this is what you want ... (get-opt :show-sql) ; need this flag

Re: clojure.string/replace-first return nil when not matched

2011-03-10 Thread Armando Blancas
1. The Clojure wrapper put the last two calls inside the if, unlike Matcher#replaceFirst(), thus the nil. public String replaceFirst(String replacement) { if (replacement == null) throw new NullPointerException(replacement); StringBuffer sb = new StringBuffer(); reset();

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Armando Blancas
You need to quote the vector so the date will be created inside eval, instead of having the date go into eval as an element of the (evaluated) vector. user= (eval '[(java.util.Date.)]) [#Date Fri Mar 11 19:59:31 PST 2011] On Mar 11, 4:37 pm, Jeffrey Schwab j...@schwabcenter.com wrote: What does

  1   2   3   >