Re: What is the meaning of :while in a for ?

2012-08-23 Thread Andy Fingerhut
I've added some examples of :when and :while, including those given by Herwig and Tassilo in this thread, at ClojureDocs: http://clojuredocs.org/clojure_core/clojure.core/for Note: Anyone with a free account can add/edit examples on that site. Andy On Aug 21, 2012, at 8:34 AM,

Re: recursion question

2012-08-14 Thread Andy Fingerhut
An additional step on top of Raoul's: Take the first #, subtract it from the goal, recursively ask if the remaining #s can sum to the now-lesser goal. If so, return yes, or the set of numbers that worked (which should include whatever was returned from the recursive call, plus the first #)

Re: Immutability rules when it comes to Ref type

2012-08-10 Thread Andy Fingerhut
Hussein: If you ignore the ref for the moment, making any change to a map, or a map nested inside a map however many levels deep you wish, does not mutate the original map. Instead it creates a brand new map with the new set of keys and values. It is as if the original was copied, and the

Re: Much longer build time for Clojure on HDD vs. SSD (4 min vs 30s)

2012-07-16 Thread Andy Fingerhut
There are links to older discussions on this topic in the description of ticket CLJ-703: http://dev.clojure.org/jira/browse/CLJ-703 Also proposed patches to Clojure, although I don't know whether some of those may lead to incorrect behavior. Andy On Jul 16, 2012, at 12:48 PM, Raju Bitter

Re: General subsequence function

2012-06-29 Thread Andy Fingerhut
the community is. :-) On Thursday, June 28, 2012 2:53:27 PM UTC-4, Andy Fingerhut wrote: From quick easy, to slower more difficult, here are some options: Use the functions you want in your own code, and find happiness in the fact that they are quick easy to write. Make a library

Re: General subsequence function

2012-06-28 Thread Andy Fingerhut
From quick easy, to slower more difficult, here are some options: Use the functions you want in your own code, and find happiness in the fact that they are quick easy to write. Make a library of this and perhaps other related functions on github. Perhaps also release JARs to clojars.org

Re: clojure.inspector.inspect-table gives up when first element is nil...

2012-06-18 Thread Andy Fingerhut
Agreed with everything Sean said, except I wanted to point out that making a unit test for functions that create GUI windows might be a little bit out of the beaten path of the existing unit tests. There may be a way to create a unit test that calls inspect-table with arguments that make it

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Andy Fingerhut
On Jun 14, 2012, at 7:59 AM, Jim - FooBar(); wrote: well, no... :-) Jim On 14/06/12 15:52, David Nolen wrote: On Thu, Jun 14, 2012 at 10:39 AM, Jim - FooBar(); jimpil1...@gmail.com wrote: Evaluates x then calls all of the methods and functions with the value of x supplied at the

Re: 'dotimes' will not work inside a 'doto'...

2012-06-14 Thread Andy Fingerhut
' somewhere centrally... Jim On 15/06/12 00:02, Andy Fingerhut wrote: On Jun 14, 2012, at 7:59 AM, Jim - FooBar(); wrote: well, no... :-) Jim On 14/06/12 15:52, David Nolen wrote: On Thu, Jun 14, 2012 at 10:39 AM, Jim - FooBar(); jimpil1...@gmail.com wrote: Evaluates x then calls

Re: Why is lein so slow?

2012-06-14 Thread Andy Fingerhut
On Jun 13, 2012, at 5:27 PM, Warren Lynn wrote: I cannot help notice that leinengen seems quite slow. Even lein help takes 8 seconds to finish printing all the information. I am using version 2 on Windows 7(that .bat file). Can anyone explain what is going on? Or is it just me? Thank you.

Re: [PATCH] RFC: Add Functions `tabify` And `untabify`

2012-06-08 Thread Andy Fingerhut
On Jun 8, 2012, at 10:58 AM, Stuart Sierra wrote: Stuart Halloway wrote: Whatever we do let's make sure we think about how to make it available in all Clojure dialects. Yes. When it comes to adding stuff to clojure.string, I'd like to focus less on adding single-purpose functions like

Re: load namespace programmatically

2012-06-08 Thread Andy Fingerhut
Does this do what you want? (defn require-from-string [s] (require (symbol s))) Andy On Jun 8, 2012, at 5:37 PM, Leandro Oliveira wrote: Hi, What is the best way to implement require-from-string? Ex: # require-from-string words like require but accepts namespaces as strings.

Re: hyphenate - imperative for

2012-06-06 Thread Andy Fingerhut
Dave: I don't know if it will help you do it more succinctly, and I don't know whether with-local-vars is implemented in ClojureScript, but at least in Clojure with-local-vars is a way to have local mutable variables in a single-threaded piece of code, and know that the mutability stays local

Re: Using Clojure internal libraries in another project

2012-06-03 Thread Andy Fingerhut
License-wise, the Clojure implementation code is copyright by Rich Hickey, and distributed under the Eclipse Public License. Thus your code would need to be distributable with a license compatible with this license, or perhaps could be completely closed source if your code was not distributed

Re: Different behavior at REPL vs compiled code

2012-05-19 Thread Andy Fingerhut
Clojure does know the type -- it knows that it is a string, rather than a number, and it does not support doing arithmetic operations on strings, hence the error. Whereas Perl would automatically convert from a string to a number in a case like this, Clojure does not. One could argue that

Re: [ANN] Clojure Namespace Browser (clj-ns-browser 1.0.0)

2012-05-16 Thread Andy Fingerhut
Did you use the instructions under Install Start-up on this page? https://github.com/franks42/clj-ns-browser Also, what OS are you using (and if Windows, are you using Cygwin, too?), and what do you get as output of the command lein version? Thanks, Andy On May 16, 2012, at 6:16 PM,

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Andy Fingerhut
If if-let/when-let had multiple bindings, how would you propose to define the condition of whether to do the then branch? As the logical AND of all of the multiple forms? The OR? Only use the first expression? Only the last? I don't see that any of those is any more clear or least

Re: Odd termination behaviour of a program that uses pmap

2012-05-08 Thread Andy Fingerhut
Not desired, but currently normal behavior. This happens whenever certain concurrency features of Clojure are used, creating other threads, and they take a while for them to be cleaned up on exit. Besides pmap, futures and a few other Clojure functions cause this. You can work around it if

Re: Odd termination behaviour of a program that uses pmap

2012-05-08 Thread Andy Fingerhut
futures, I've added examples to those two functions that recommend reading the examples for future. Andy On May 8, 2012, at 11:18 AM, Andy Fingerhut wrote: Not desired, but currently normal behavior. This happens whenever certain concurrency features of Clojure are used, creating other threads

How to handle dependencies on multiple versions of the same library?

2012-05-02 Thread Andy Fingerhut
I haven't actually run across this before, but I suspect someone else has. I was curious how people handle it. Suppose you have your project A, and it uses Leiningen (the issue is more widely applicable, but for the sake of example). * A depends on some version of library B, which in turn

Re: (update-in) and getting the new value at the leaf efficiently

2012-04-26 Thread Andy Fingerhut
Here is one way to do it called update-in+. It returns a vector consisting of the new udpated value, like update-in does, followed by the original value (in case you might want to see that for some reason), followed by the updated value. (defn update-in+ ([m [k ks] f args] (if ks

Clojure cheatsheets with several flavors of tooltips

2012-04-23 Thread Andy Fingerhut
The tooltip version of the Clojure/Java cheatsheet is not published at [1] just yet, but hopefully we can figure out how to make that happen in a while: [1] http://clojure.org/cheatsheet There is an updated link at the bottom of that page called Download other versions that leads to [2]: [2]

Andy Fingerhut wants to chat

2012-04-14 Thread Andy Fingerhut
--- Andy Fingerhut wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-d7d845b242-b84a102cf0-A1gnhr4A2hNcJ4MUjH_o4M_4vTk

Re: Boolean

2012-04-13 Thread Andy Fingerhut
One little nit that confuses me. Boolean/FALSE is documented as being of type Boolean in Java documentation, yet it is treated by Clojure the same as primitive boolean false: user= (clojure-version) 1.3.0 user= (if Boolean/FALSE logical true logical false) logical false user= (identical?

Re: Boolean

2012-04-12 Thread Andy Fingerhut
I know that having such things in the doc strings would probably be your ideal, but note that clojuredocs.org is editable by anyone, and one could in a few minutes create an account there and document what they consider corner cases. I don't know where you'd most like to find these kinds of

Re: Read in a big file and get GC limit/outofmemory error.

2012-04-11 Thread Andy Fingerhut
On Apr 9, 2012, at 10:05 PM, Andy Wu wrote: Hi there, I'm studying algo-class.org, and one of it's programming assignment gives you a file containing contents like below: 1 2 1 7 2 100 ... There is roughly over 5 million lines, and i want to first construct a vector of vector of

Slides with some basics on Clojure documentation

2012-04-06 Thread Andy Fingerhut
Slides aren't usually as fun without the talk that comes with them, but I don't think it was recorded. Nothing too fancy here -- just some slides I used at a discussion we had on Clojure documentation at last night's Bay Area Clojure User Group monthly meetup:

Re: SubVec anomaly

2012-03-29 Thread Andy Fingerhut
Thanks for the catch. Bug report with patch created: http://dev.clojure.org/jira/browse/CLJ-962 Andy On Mar 29, 2012, at 2:15 AM, stirfoo wrote: user= (nth (subvec [:??? 1 2] 1) -1) :??? This could be a bug, not sure. Only the upper bound of the internal SubVec is being checked.

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-28 Thread Andy Fingerhut
it better. Andy On Mar 27, 2012, at 3:41 PM, Andy Fingerhut wrote: I would be happy to, if someone could teach me how to do it. I didn't write the JavaScript that does the tooltips -- I just took the TipTip jQuery plugin and bashed away at it slightly until it did what I wanted. I've tried using

Re: GSOC Idea: Interactive documentation with autodoc

2012-03-28 Thread Andy Fingerhut
My fork of cd-client has code to create a local snapshot of all examples, see-alsos, and comments in clojuredocs.org, save it to a file, and switch to local mode, which pulls all results from the snapshot file instead of clojuredocs.org. https://github.com/jafingerhut/cd-client Andy On Mar

Re: beginner - stuck in dependencies and possibly old versions

2012-03-27 Thread Andy Fingerhut
I've installed Leiningen on many machine following the brief installation instructions here: https://github.com/technomancy/leiningen If you put 1.3.0 version of Clojure in your project.clj and do lein deps, it should download that version of Clojure into the lib directory of your project.

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-27 Thread Andy Fingerhut
and that causes the popup to disappear. On Monday, March 26, 2012 2:25:17 PM UTC-7, Andy Fingerhut wrote: Welcome, Pierre. Thanks for the info. My current thinking is to start publishing on clojure.org two, or maybe even three versions of the cheatsheet: (1) no tooltips, just like

Re: Clojure cheatsheet with tooltips (alpha)

2012-03-26 Thread Andy Fingerhut
, including my modified jQuery TipTip plugin, are here: https://github.com/jafingerhut/clojure-cheatsheets Andy On Mar 24, 2012, at 3:15 AM, Andy Fingerhut wrote: There are still some problems with this, but it is ready for experimental use, at least. Alex, please don't put this on clojure.org

Re: Clojure cheatsheet with tooltips (alpha)

2012-03-26 Thread Andy Fingerhut
. All necessary files to generate these pages, including my modified jQuery TipTip plugin, are here: https://github.com/​jafingerhut/clojure-​cheatsheets Andy On Mar 24, 2012, at 3:15 AM, Andy Fingerhut wrote: There are still some problems with this, but it is ready for experimental

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-26 Thread Andy Fingerhut
who stretch the original intent of these mechanisms, I do so proudly :-) Andy On Mar 25, 2012, at 10:36 PM, Pierre Mariani wrote: On Saturday, March 24, 2012 11:59:49 PM UTC-7, Andy Fingerhut wrote: I've tried again using links with doc strings as the values of the title attribute

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-25 Thread Andy Fingerhut
I've tried again using links with doc strings as the values of the title attribute, but when the text in Firefox 11.0 it does not honor the line breaks in my text, but reflows it. Try it out yourself at [1]: [1]

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-25 Thread Andy Fingerhut
On Mar 25, 2012, at 12:15 AM, Cedric Greevey wrote: On Sun, Mar 25, 2012 at 2:59 AM, Andy Fingerhut andy.finger...@gmail.com wrote: I've tried again using links with doc strings as the values of the title attribute, but when the text in Firefox 11.0 it does not honor the line breaks in my

Clojure cheatsheet with tooltips (alpha)

2012-03-24 Thread Andy Fingerhut
There are still some problems with this, but it is ready for experimental use, at least. Alex, please don't put this on clojure.org -- it ain't ready yet. http://homepage.mac.com/jafingerhut/files/cheatsheet-clj-1.3.0-v1.4-tooltips/cheatsheet-full.html I found and used TipTip for tooltips [1],

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-23 Thread Andy Fingerhut
I definitely like the tooltip idea. I like it so much that I've already played with it a bit, looking at several web pages with instructions for how to do it, but my knowledge of good ways to do this is zero except for the results of those Google searches. Has anyone implemented tooltips on a

Re: removing a hash-map from a set using hash-map's field.

2012-03-23 Thread Andy Fingerhut
Sets are good when you have a collection of things, the precise order isn't important to you, and you want to avoid duplicates. I used one in some code recently where I wanted to maintain a collection of people who were co-authors in a Clojure patch, and the input file I started with could

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-23 Thread Andy Fingerhut
On Fri, Mar 23, 2012 at 12:50 PM, Cedric Greevey cgree...@gmail.com wrote: On Fri, Mar 23, 2012 at 10:58 AM, Andy Fingerhut andy.finger...@gmail.com wrote: I definitely like the tooltip idea. I like it so much that I've already played with it a bit, looking at several web pages

Re: New(er) Clojure cheatsheet hot off the presses

2012-03-23 Thread Andy Fingerhut
PM, Cedric Greevey cgree...@gmail.com wrote: On Fri, Mar 23, 2012 at 3:57 PM, Andy Fingerhut andy.finger...@gmail.com wrote: Thanks for the suggestions, folks. Cedric, have you tried your method before? I'm not sure, but I think it was the thing that I tried that led me to add (b) to my

New(er) Clojure cheatsheet hot off the presses

2012-03-22 Thread Andy Fingerhut
Alex Miller not only organizes conferences that are a blast to attend (i.e. Clojure/West, and I'm inclined to believe Strange Loop would be cool, too), he also puts up new versions of the Clojure cheatsheet when I ask him nicely. Here it is, in the usual place: http://clojure.org/cheatsheet

Re: into applied to transient vectors undocumented?

2012-03-20 Thread Andy Fingerhut
into uses transient and persistent! for speed. The fact that into can take a transient as input is an accidental consequence of that, I think. Before into was changed to use transients internally, it could only take persistent data structures as input, and return a persistent data structure.

Re: into applied to transient vectors undocumented?

2012-03-20 Thread Andy Fingerhut
return a persistent collection, right? :) thx Las 2012/3/20 Andy Fingerhut andy.finger...@gmail.com into uses transient and persistent! for speed. The fact that into can take a transient as input is an accidental consequence of that, I think. Before into was changed to use transients

Re: into applied to transient vectors undocumented?

2012-03-20 Thread Andy Fingerhut
to clojure.lang.IPersistentCollection clojure.core/conj (core.clj:83) user= (into x [5 6 7]) [1 2 3 5 6 7] Andy On Mar 20, 2012, at 11:30 AM, Andy Fingerhut wrote: func! (bang) is a naming convention from the programming language Scheme that Clojure often uses. In general it means that the function mutates data, i.e

Re: understanding data structures, and other low-level stuff

2012-03-19 Thread Andy Fingerhut
, and then jump to those specific sections. Save all the stuff on algorithms for when and if you are interested. Andy On Mar 18, 2012, at 8:57 PM, Andy Fingerhut wrote: Feel free to ask follow-up questions on the basics privately, since many Clojure programmers are probably already familiar

Re: Returning Success

2012-03-19 Thread Andy Fingerhut
I liked approach 2 myself, if the goal is to stick with pure functions when it isn't too difficult. It avoids the comparison of 1, and gets you back exactly the info you want to go onwards from there. You can add a caveat that I haven't written a lot of application code with Clojure, so

Re: understanding data structures, and other low-level stuff

2012-03-18 Thread Andy Fingerhut
Feel free to ask follow-up questions on the basics privately, since many Clojure programmers are probably already familiar with them, whereas follow-up questions on persistent data structures are very on-topic, since I would guess many people who have studied computer science and/or programming

Re: How to escape a space in a keyword?

2012-03-13 Thread Andy Fingerhut
Thanks. These are now available on clojuredocs.org pages for functions keyword and symbol: http://clojuredocs.org/clojure_core/clojure.core/symbol http://clojuredocs.org/clojure_core/clojure.core/keyword linked to from: http://clojure.org/cheatsheet Andy On Mar 12, 2012, at 10:11 PM, Frank

Re: How to escape a space in a keyword?

2012-03-13 Thread Andy Fingerhut
(kotarak) wrote: Hi, Am Dienstag, 13. März 2012 07:46:58 UTC+1 schrieb Andy Fingerhut: http://clojuredocs.org/clojure_core/clojure.core/symbol And right below is an example of invalid usage. Sincerely Meikel -- You received this message because you are subscribed to the Google

Re: How to escape a space in a keyword?

2012-03-13 Thread Andy Fingerhut
Ah, my senior moment was not noticing the invalid example use of symbol in the second example, which was passing strings of decimal digits to symbol. I went ahead and deleted that one. Thanks, Andy On Mar 13, 2012, at 12:04 AM, Andy Fingerhut wrote: Which one? (symbol 'foo) (symbol

Re: Can Clojure be as readable as Python or Ruby ?

2012-03-07 Thread Andy Fingerhut
You might have a difficult time getting other Clojure coders to adopt the practice in their code, but would this be almost as good? (let [x 2] code) Achieving that would be as simple as hand-indenting it that way, or adjusting the auto-indenter of your favorite text editor to do it that way.

Re: clojure url exception

2012-03-03 Thread Andy Fingerhut
I'm not sure what it is, but here is another transcript that may provide additional clues, and with a slightly later version of Clojure: user= (clojure-version) 1.4.0-beta1 user= (def x #java.net.URL[file:/home/hara/dj/usr/src/clojurescript/src/cljs/cljs/core.cljs]) #'user/x user= x #URL

Re: clojure url exception

2012-03-03 Thread Andy Fingerhut
/cljs/core.cljs]] (printf (class x)=%s x='%s'\n (class x) x)) (class x)=class clojure.lang.Symbol x='file:/home/hara/dj/usr/src/clojurescript/src/cljs/cljs/core.cljs' nil Andy On Mar 3, 2012, at 12:08 PM, Andy Fingerhut wrote: I'm not sure what it is, but here is another transcript that may

Re: using contains? on transient collections

2012-02-29 Thread Andy Fingerhut
Some related JIRA tickets, http://dev.clojure.org/jira/browse/CLJ-700 http://dev.clojure.org/jira/browse/CLJ-757 http://dev.clojure.org/jira/browse/CLJ-932 All have patches, although I don't personally know whether they are correct fixes. Andy On Feb 29, 2012, at 10:08 PM, Mark Engelberg

Re: Clojure 1.3 updated cheatsheet with links to clojuredocs.org

2012-02-27 Thread Andy Fingerhut
for the cheatsheet contents? On Feb 27, 7:57 am, Bill Caputo logos...@gmail.com wrote: On Feb 27, 2012, at 1:22 AM, Andy Fingerhut wrote: Thanks to several people who provided feedback, especially Steve Miner, and to Alex Miller for updating the web site yet again, there is a new cheatsheet

Re: Clojure 1.3 updated cheatsheet with links to clojuredocs.org

2012-02-27 Thread Andy Fingerhut
Cedric: At the bottom of the main clojuredocs.org page is the text below. I've copied it here because perhaps the best way to get such changes made is to contribute changes to the code of the clojuredocs.org web site. At the least, it would be good to open a case. You'll have to go to the

Clojure 1.3 updated cheatsheet with links to clojuredocs.org

2012-02-26 Thread Andy Fingerhut
of structmaps (defrecord is recommended) + Moved Regex functions to strings section I'm not planning on any more updates soon, but if anyone has suggestions for further improvements, please contact me. Andy On Feb 20, 2012, at 1:30 PM, Andy Fingerhut wrote: This will likely go live

Re: Bret Victor - Inventing on Principle

2012-02-24 Thread Andy Fingerhut
Perhaps someone will volunteer to transcribe it and post that. You know, maybe someone who can type quickly and prefers text. :-) I've done that for one of Rich's earlier talks posted as video. It takes time, and I'm not volunteering for this one. Andy On Feb 24, 2012, at 11:57 AM, Cedric

Re: clojure thesis opportunity

2012-02-22 Thread Andy Fingerhut
I haven't written such code myself, but one motivation for creating Erlang was software for telecommunications systems, where they have very high uptime requirements and needed the ability to update code on a running system. It can replace definitions of functions in place as well as any Lisp.

Re: Clojure 1.3.0 updated cheatsheet, and one with links to clojuredocs.org

2012-02-20 Thread Andy Fingerhut
) + Moved Regex functions to strings section More details on changes made since sheet version 1.0: http://homepage.mac.com/jafingerhut/files/cheatsheet-clj-1.3.0-v1.2/CHANGELOG.txt Andy On Feb 15, 2012, at 11:21 AM, Andy Fingerhut wrote: Fogus, Alex Millier, and I have made some updates

Re: bug in clojure.repl/doc to print namespace docs (?)

2012-02-20 Thread Andy Fingerhut
Yep, and there is a patch ready to go in JIRA: http://dev.clojure.org/jira/browse/CLJ-902 Andy On Feb 20, 2012, at 3:17 PM, Frank Siebenlist wrote: When I request the doc for a namespace, an exception gets thrown (clojure 1.3): user= (doc clojure.core) ClassNotFoundException

Re: Clojure 1.3.0 updated cheatsheet, and one with links to clojuredocs.org

2012-02-20 Thread Andy Fingerhut
browser window when looking at those pages. Andy On Feb 20, 2012, at 1:39 PM, Weber, Martin S wrote: On 2012-02-20 16:30 , Andy Fingerhut andy.finger...@gmail.com wrote: This will likely go live on clojure.org/cheatsheet in a few days, but I want to give it a little longer for folks to have

Clojure 1.3.0 updated cheatsheet, and one with links to clojuredocs.org

2012-02-15 Thread Andy Fingerhut
Fogus, Alex Millier, and I have made some updates to the Clojure cheatsheet for Clojure 1.3.0: http://clojure.org/cheatsheet The links there go to the generated documentation on clojure.github.com. Below is a version that is the same as the one above, except that its links go to the

Improved apropos

2012-02-06 Thread Andy Fingerhut
I have occasionally been frustrated by the behavior of apropos because it returns a list of matching symbols, but with no clue as to which namespace those symbols are in. I wrote a couple of functions to help with this, apropos2 and unresolve. https://gist.github.com/1757414 apropos2 is like

Re: Why don't these two functions produce equivalent results?

2012-01-28 Thread Andy Fingerhut
One way to think of it is that both assoc and assoc! create and return new maps that are different than the originals they were given as input. assoc never modifies the original map. assoc! might, or it might not. It depends on implementation details. A correct Clojure program will never rely

Re: Literate programming in emacs - any experience?

2012-01-23 Thread Andy Fingerhut
I've only briefly scanned what I think is the relevant code in tangle.lisp posted by Tim Daly, but it appears that the @ must be the first character on a line, which with indenting I've never seen in a Clojure source file. It would be a tiny change to make the @ required to be on a line by itself,

Re: strange problem

2012-01-17 Thread Andy Fingerhut
On Tue, Jan 17, 2012 at 4:35 AM, Rasmus Svensson r...@lysator.liu.sewrote: You can use this as a temporary workaround: (require '[clojure.string :as str]) (defn strip-supplementary [s] (str/replace s #[^\u-\u]+ (removed supplementary characters)))

Re: strange problem

2012-01-16 Thread Andy Fingerhut
I don't have enough knowledge to tell you Oh, just do this, and your Emacs issues will be solved. but I can give some hints as to what these characters are, so perhaps others can say, or you can direct your Google searches in a more focused manner. I believe those are Unicode characters, and ones

Re: converting a string to a list

2012-01-14 Thread Andy Fingerhut
This may not be important for your application, but if what you want in the returned sequence are strings, and if you expect to deal with Unicode characters that are not in the Basic Multilingual Plane (BMP) set, then note the following differences. (map str s) will return a separate string for

Re: Map/Reduce Performance Question

2012-01-13 Thread Andy Fingerhut
If I am reading your example correctly, that pmap is simply being used to iterate over the characters of a line read into a string, then yes, you are using pmap in a very inefficient way. pmap creates a future for every element of the sequence you give it, and that is significantly more

Any char-based Java file I/O with arbitrary seek?

2012-01-05 Thread Andy Fingerhut
If this doesn't seem like a question for a Clojure group, I'll preface this by saying it is motivated by writing Clojure examples for a Clojure cookbook [1]. So far the examples are intended to work like the Perl examples from the 1st edition of the Perl Cookbook [2], but it may grow beyond that

Any built-in way to print to stream besides *out*?

2011-12-31 Thread Andy Fingerhut
I know I can bind *out* to another stream like *err*, but is that the only way built-in to Clojure? (binding [*out* *err*] (println This will go to *err*, not *out*)) If it is the only way, is there some library perhaps where someone has implemented a function that lets you specify the output

Re: Any built-in way to print to stream besides *out*?

2011-12-31 Thread Andy Fingerhut
: Like this? (defn printf+ [ [writer more :as xs]] (if (instance? java.io.PrintWriter writer) (binding [*out* writer] (apply println more)) (apply println xs))) On Sat, Dec 31, 2011 at 10:01 AM, Andy Fingerhut andy.finger...@gmail.com wrote: I know I can bind *out

Re: How to get the vector?

2011-12-20 Thread Andy Fingerhut
Those are native Java arrays you are getting. If you see things like 'int[]', 'double[]', that is a hint. Also the '[I' and '[D' are abbreviated type specifiers for such things in certain contexts in Clojure. I think the hex string is an address, or Java object ID, or something like that. You

Re: Read linux PATH in clojure

2011-12-17 Thread Andy Fingerhut
Here is a one-line transcript in a REPL showing an example of getting the value of the environment variable PATH: user= (get (System/getenv) PATH)

Re: Read linux PATH in clojure

2011-12-17 Thread Andy Fingerhut
Argh. Hit send without rereading my example more carefully. I misplaced a paren in my final example. It should have been: (.SetFilePrefix (str (get (System/getenv) VTK_DATA_ROOT) /Data/headsq/quarter)) Andy On Sat, Dec 17, 2011 at 5:01 PM, Andy Fingerhut andy.finger...@gmail.comwrote

Can JVM GC be tweaked to quickly reuse memory of objects that soon become garbage?

2011-12-16 Thread Andy Fingerhut
This is a question about Clojure performance on the JVM. There might be similar but different tweaks on the CLR or for ClojureScript, but I'm only curious about those if someone knows how to achieve the desired performance improvements today. I can give more concrete examples if there is

Re: Opposite function to cons, but in terms of construction, not destruction.

2011-12-10 Thread Andy Fingerhut
conj adds an element to a data structure in a place most efficient for the particular type of data structure. For lists, this is at the beginning. For vectors, it is at the end: user= (conj (conj (conj '(1 2 3) 4) 6) 7) (7 6 4 1 2 3) user= (conj (conj (conj [1 2 3] 4) 6) 7) [1 2 3 4 6 7] If you

Re: Opposite function to cons, but in terms of construction, not destruction.

2011-12-10 Thread Andy Fingerhut
at finger trees, which Chouser has implemented for Clojure: https://github.com/clojure/data.finger-tree Andy On Sat, Dec 10, 2011 at 6:43 AM, Andy Fingerhut andy.finger...@gmail.comwrote: conj adds an element to a data structure in a place most efficient for the particular type of data structure

Macro to ease multiple-key sorting

2011-12-07 Thread Andy Fingerhut
I've been going through the PLEAC web site, writing Clojure examples corresponding to the Perl code examples from the Perl Cookbook: http://pleac.sourceforge.net Michael Bacarella started a github repo to collect these together, and I'm helping flesh some of them out.

Re: Macro to ease multiple-key sorting

2011-12-07 Thread Andy Fingerhut
zero? (map #(compare (% a) (% b)) keys))) 0))) (sort-by (multicmp =) coll) On Dec 7, 5:51 pm, Andy Fingerhut andy.finger...@gmail.com wrote: I've been going through the PLEAC web site, writing Clojure examples corresponding to the Perl code

Re: Macro to ease multiple-key sorting

2011-12-07 Thread Andy Fingerhut
for :name, but explicit ascending order for :salary: (pprint (sort (multicmp :name [- :age] [+ :salary]) employees)) Thanks, Andy On Wed, Dec 7, 2011 at 7:23 PM, Andy Fingerhut andy.finger...@gmail.comwrote: The intent of making it a macro is that it allows short-circuit evaluation, like

Re: Macro to ease multiple-key sorting

2011-12-07 Thread Andy Fingerhut
On Wed, Dec 7, 2011 at 8:29 PM, Alan Malloy a...@malloys.org wrote: On Dec 7, 8:12 pm, Andy Fingerhut andy.finger...@gmail.com wrote: Ugh. And if I were slightly lazier at pressing the send button, I would have realized that the laziness of map and remove gives this short-circuit

ANN: clojuredocs REPL client with off-line mode

2011-12-06 Thread Andy Fingerhut
This is still early, but it might be in a form where someone would like to use it, and I'd appreciate suggestions on what would make it more useful. It is a fork of the clojuredocs client created by Lee Hinman, with some additions so that you can either run it in the default web mode, where it

Re: Potential bug: pmap vs chunked seqs

2011-10-23 Thread Andy Fingerhut
It isn't hard to write your own variation of pmap that does not do more parallelism than you want, regardless of whether the input sequence is chunked or not. I wrote one for a Clojure submission to the computer language benchmarks game a year or so ago. Besides avoiding unwanted parallelism for

Re: Spread work onto multiple threads (in pure Clojure)

2011-10-11 Thread Andy Fingerhut
One benefit would be convenience of enabling parallelism on nested data structures. One function at the top level could use parallelism, and the pieces, perhaps handled by separate functions, and perhaps nested several levels deep in function calls, could also use parallelism. If it were

Re: Spread work onto multiple threads (in pure Clojure)

2011-10-10 Thread Andy Fingerhut
I'll post more on this later, but I wanted to point out one case where I found that pmap was not achieving the desired level of speedup (# of CPUs/cores) that you would initially expect, and it is not due to any reasons that I've posted about before. Imagine a 4-core CPU. There are 4 physical

Re: suggestion for clojure development

2011-10-01 Thread Andy Fingerhut
Tal, did you consider the possibility of staying with Clojure 1.2.1 and its libraries? Or was that not under consideration for some reason? Andy On Sat, Oct 1, 2011 at 6:03 PM, Tal Liron tal.li...@gmail.com wrote: On Tuesday, September 27, 2011 1:57:03 PM UTC-5, Arthur Edelstein wrote: So

Re: Clojure v1.4 - what is new, changed and in development

2011-09-27 Thread Andy Fingerhut
Pardon my ignorance -- I've not done anything with AJAX before. Is there a way to do this in a single HTML file, and include all of the tooltips in that file? If so, do you have an example of this I could use to learn from? Just two or three links each with different tooltips would be enough to

Re: can't see the error

2011-09-26 Thread Andy Fingerhut
This: randomPoint #(apply new point (repeatedly 3 randomInt)) does not work, but is almost what you want. It doesn't work because new is a macro, and apply only works with functions as the first arg. Using the following two lines, first to define a function, then to use it with apply, seems

Re: beginner question

2011-09-25 Thread Andy Fingerhut
All persistent data structures are immutable, but not all immutable data structures are persistent. For example, imagine an immutable array that, unlike Clojure's vector data structure, implemented conj by copying the entire array into a new one with the original elements plus the new one.

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-24 Thread Andy Fingerhut
resource contention, etc. I have similar issues sometimes when I launch parallel threads via sends to agents. Will this behave similarly to pmap? If so, is there a straightforward way to get the same kind of benefit as medusa-pmap in an agent context? -Lee On Sep 22, 2011, at 11:34 PM, Andy

Re: Addition of new a priori distinct element to a vector

2011-09-23 Thread Andy Fingerhut
To be very precise, (conj v new-elem) is O(log n) in time and space, but it is constant-ish because the base of the logarithm is something like 32, rather than something like 2, so the constant factor multiplying the log n is typically pretty small. Also, there is no difference in Clojure's

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-22 Thread Andy Fingerhut
pmap will limit the maximum number of simultaneous threads. So will the medusa library's medusa-pmap. The difference is that if one job early in the list takes, e.g., 100 times longer than the next 20, and you have 4 cpus available, pmap will start the first (4+2)=6 in parallel threads, let jobs

Re: Spread work onto multiple threads (in pure Clojure)

2011-09-21 Thread Andy Fingerhut
pmap already uses future/deref in its implementation. When it does so, it limits the *maximum* parallelism possible to be at most (number-of-cpus + 2) threads running at a time, and depending upon the time taken by each of the objects you are mapping over, it can be less then that. I don't know

Re: cheatsheet problem

2011-09-20 Thread Andy Fingerhut
There is definitely a particular width that it was made for the layout to work well. I'm not enough of an HTML guru to know whether there is a good way to make it automatically adjust to display at other screen widths, but if you or someone else is, you can download the Clojure program that

Re: Language shoutout clojure code does not have types

2011-09-18 Thread Andy Fingerhut
Everyone is welcome to make faster versions if they can figure out how. I suspect that most of the time is spent in BigInteger math in that particular program. If so, type annotation won't speed that up. Glad to be proved wrong, though! Andy On Sun, Sep 18, 2011 at 12:02 AM, Vagif Verdi

Re: Language shoutout clojure code does not have types

2011-09-18 Thread Andy Fingerhut
if such a submission would be acceptable. Andy On Sun, Sep 18, 2011 at 8:16 AM, Andy Fingerhut andy.finger...@gmail.comwrote: Everyone is welcome to make faster versions if they can figure out how. I suspect that most of the time is spent in BigInteger math in that particular program. If so, type annotation

<    3   4   5   6   7   8   9   >