lazy maps in Clojure?

2013-01-20 Thread Larry Travis
One of the neat things about Clojure (maybe all functional languages) is that functions can be defined either extensionally or intensionally. How can one create a Clojure structure that mixes these two types of definition? That is, I would like to define a function f that saves its result the

Re: lazy maps in Clojure?

2013-01-21 Thread Larry Travis
Mon, Jan 21, 2013 at 7:27 AM, Larry Travis > wrote: One of the neat things about Clojure (maybe all functional languages) is that functions can be defined either extensionally or intensionally. How can one create a Clojure structure tha

functions as return values

2013-02-23 Thread Larry Travis
In Clojure, if I have a function call that asks for return of a function, for example user> ((fn [a] (fn [b] (+ (inc a) (* b b 5) I get the function name # But what I would like to get is an expression that defines this function, for example (fn [b] (+ 6 (* b b))) Is there some way th

Re: functions as return values

2013-02-23 Thread Larry Travis
until values for their open variables become available. --Larry On 2/23/13 5:50 PM, Michael Klishin wrote: 2013/2/24 Larry Travis mailto:tra...@cs.wisc.edu>> Is there some way that I can suppress the evaluation of this expression? ((fn [a] '(fn [b] (+ (inc a) (* b

Need help getting Snow Leopard, Aquamacs, Clojure, and Slime to work

2010-06-20 Thread Larry Travis
lime/, I also get an error message but a different one, viz. "Searching for program: No such file or directory, lisp". I hope somebody has an answer for me w.r.t. Aquamacs, but I will be happy if I can get either version of Emacs to work with clojure and slime. Thanks. --Larry T

Re: Need help getting Snow Leopard, Aquamacs, Clojure, and Slime to work

2010-06-22 Thread Larry Travis
figure it out with some exploration. --Larry Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your f

Re: Need help getting Snow Leopard, Aquamacs, Clojure, and Slime to work

2010-06-22 Thread Larry Travis
s -- adapting them to Aquamacs if I can. --Larry Travis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with yo

Re: Need help getting Snow Leopard, Aquamacs, Clojure, and Slime to work

2010-06-23 Thread Larry Travis
Thanks again. I have to be away from home and my iMac for the next ten days so it will be some time before I can work through your suggestions, but I will certainly give them a try. I'll let you know what kind of success I have. I very much appreciate your help. --Larry Travis Joost

Re: A newbie's summary - what worked, what didn't

2011-03-28 Thread Larry Travis
Kasim: I just discovered ClojureW, and it looks promising. I will report my reaction after I get time to thoroughly test it for the kinds of things I am doing. In the meantime, a request: When you work 'on a "Just Works" emacs setup' for Mac Os X consider whether you can create such a setup

can't set up Clojure 1.2.1

2011-07-14 Thread Larry Travis
I need to upgrade from the older version of Clojure I have been using so I downloaded Version 1.2.1 and followed these instructions from http://clojure.org/getting_started: In the directory in which you expanded clojure.zip, run: java -cp clojure.jar clojure.main This will bring up a simple r

Re: can't set up Clojure 1.2.1

2011-07-14 Thread Larry Travis
Jonathan: Thanks. When the instructions said "the directory in which you expanded clojure.zip" I took that to mean the directory I was in when I expanded clojure.zip, not the directory that was created to hold the zip-file contents. --Larry On 7/14/11 10:05 PM, Jonathan Cardoso wrote: Wei

Re: can't set up Clojure 1.2.1

2011-07-15 Thread Larry Travis
Thanks, Sergey. The problem was indeed a classpath problem. The part of my ignorance about Java that seems to cause me the most trouble is my ignorance about Java classpaths. I think some Clojurians underestimate the difficulties involved in learning Clojure without knowing Java first. I wish

Re: can't set up Clojure 1.2.1

2011-07-16 Thread Larry Travis
uter science -- at least, for the very important areas of programming multi-processor systems and of experimental programming (so important, for example, for artificial intelligence research). --Larry On 7/16/11 10:10 AM, Phil Hagelberg wrote: On Fri, Jul 15, 2011 at 11:29 PM, Larry Travi

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread Larry Travis
I too think this is interesting because because it serves to illustrate some important general aspects of Clojure with a very simple problem. I wrote four Clojure programs contrasting different ways of solving the problem, and then timed the application of each ten times to a million-item sequ

Leiningen-noobie question

2012-04-28 Thread Larry Travis
I have installed Leiningen not so much to manage projects but to enable use of /clojure-jack-in/ as a means of getting Swank and Slime to work. And they do work for me. But now I have a question that I can't find an answer for in any Leiningen documentation I know about. I have a largish, pr

Re: Leiningen-noobie question

2012-04-28 Thread Larry Travis
n Corfield wrote: On Sat, Apr 28, 2012 at 12:21 AM, Larry Travis wrote: I have installed Leiningen not so much to manage projects but to enable use of clojure-jack-in as a means of getting Swank and Slime to work. And they do work for me. But now I have a question that I can't f

Re: Leiningen-noobie question

2012-04-28 Thread Larry Travis
programs to work than on getting my programming environment to work. If you get any more ideas about how I might try to solve my problem, let me know. Thanks. --Larry On 4/28/12 5:07 PM, Sean Corfield wrote: On Sat, Apr 28, 2012 at 2:41 PM, Larry Travis wrote: That is, what would cor

Re: Leiningen-noobie question

2012-04-28 Thread Larry Travis
/twitter.com/#%21/sw1nn>, w: sw1nn.com <http://sw1nn.com/> } On Sun, Apr 29, 2012 at 12:42 AM, Larry Travis <mailto:tra...@cs.wisc.edu>> wrote: Sean: Your suggestion doesn't work. The Slime REPL comes up fine when I use the dependency vector you suggest (some

Re: Leiningen-noobie question

2012-04-30 Thread Larry Travis
Phil, Neale, Sean: You guys are all way ahead of me as to why I am getting the results I am getting, but it is only Neale's advice that works. That is [prjctOne/prjctOne "1.0.0-SNAPSHOT"] works, but [prjctOne "1.0.0-SNAPSHOT"] does not. --Larry On 4/30/12 11:14 AM, Phil Hagelberg wro

Re: Leiningen-noobie question

2012-05-02 Thread Larry Travis
robably already knew that they would!) --Larry On 5/1/12 11:22 AM, Phil Hagelberg wrote: On Mon, Apr 30, 2012 at 9:28 PM, Larry Travis wrote: Phil, Neale, Sean: You guys are all way ahead of me as to why I am getting the results I am getting, but it is only Neale's advice that works.

Why doesn't doc work in clojure-jack-in slime-repl?

2012-05-04 Thread Larry Travis
A command like user> (doc hash-map) in the slime-repl created by clojure-jack-in results in Unable to resolve symbol: doc in this context [Thrown class java.lang.RuntimeException] Can this be fixed or do I have to do my doc requests someplace else? --Larry -- You received this message

Re: Why doesn't doc work in clojure-jack-in slime-repl?

2012-05-04 Thread Larry Travis
Thank you, Roberto. Works like a charm. --Larry On 5/4/12 2:32 PM, Roberto Mannai wrote: You should "use" it: user> (use 'clojure.repl) nil user> (doc doc) ... On Fri, May 4, 2012 at 9:27 PM, Larry Travis <mailto:tra...@cs.wisc.edu>> wrote: A command

Re: Why doesn't doc work in clojure-jack-in slime-repl?

2012-05-04 Thread Larry Travis
Roberto: This indeed looks like it will be useful. Thanks. Your require-all-snippet.clj script loaded OK except for: Attempting to require clojure.parallel : couldn't require clojure.parallel Exception #java.lang.ClassNotFoundException: jsr166y.forkjoin.ParallelArray> --Larry On 5/4/1

Re: Why doesn't doc work in clojure-jack-in slime-repl?

2012-05-04 Thread Larry Travis
Phil: Thanks. I obviously need to start doing my Clojure programming with a Slime cheatsheet in front of me! --Larry On 5/4/12 4:00 PM, Phil Hagelberg wrote: Another way to do it is just use C-c C-d C-d for docs lookup. -Phil -- You received this message because you are subscribed to th

Re: Best Clojure Learning Resource for Lisper

2012-05-07 Thread Larry Travis
Lee's comments ring true for me so let me extend them. Before I discovered Clojure, my experience as a programmer had been mainly in the area of artificial-intelligence experimental programming. I was once a reasonably proficient Lisp programmer, but pre-CL and pre-CLOS, that is, mainly using

Re: Best Clojure Learning Resource for Lisper

2012-05-07 Thread Larry Travis
Sean and Lee: In general, I have considered the difference between Aquamacs and GNU Emacs to be that the former prioritizes computer-user interaction via mouse, command-bars and menus (which requires a lot of hand movement between keyboard and mouse, but enables the user to dispense with memor

How do I set jvm options for a lein repl

2012-05-20 Thread Larry Travis
How do I set jvm options for a /lein repl/ initiated independently of a project? In particular, I want the heap expansion that results from doing "M-x clojure-jack-in" in an emacs /project.clj/ buffer with ":jvm-opts [ "-Xms4G" "-Xmx4G"]" in its defproject form. --Larry -- You received thi

Re: How do I set jvm options for a lein repl

2012-05-21 Thread Larry Travis
I should be switching over to Leiningen 2 shortly in any case, but I am curious. How does one "set JVM_OPTS as an environment variable"? --Larry On 5/21/12 11:42 AM, Phil Hagelberg wrote: On Mon, May 21, 2012 at 5:28 AM, Raju Bitter wrote: How do I set jvm options for a lein repl initiated

Re: How do I set jvm options for a lein repl

2012-05-21 Thread Larry Travis
It took me a while to figure out how to put multiple entries into an environment variable (that is, settings for both min and max heap sizes, to wit, "export JVM_OPTS=\ -Xms4G\ -Xmx4G") but, once I did, Phil's and Luc's suggestions have worked well and things have gone swimmingly. They work for

Re: General subsequence function

2012-06-27 Thread Larry Travis
Something like this will give you what you want: (defn subseqx [s start end] (cond (instance? clojure.lang.IPersistentVector s) (subvec s start end) (instance? java.lang.String s) (subs s start end) :else (let [slice (dr

Can I examine the state of a Clojure lazy sequence?

2012-07-08 Thread Larry Travis
(1) Is there any way I can extract from a Clojure lazy sequence at some given point in its use those of its members that have so far been realized? For example, can I extract the cache of realized members, turn it into a vector, and then process that vector independently of further use of the l

Meaning of "="

2012-10-02 Thread Larry Travis
What is the rationale for this? user> (= [1 2 3 4] '(1 2 3 4)) true I was quite surprised when this turned out to be the cause of a bug in a function I am constructing. Vectors and lists differ so substantially in their implementation and in their behavior that a vector and a list should no

What is this function?

2012-10-09 Thread Larry Travis
As participants in this googlegroup have often observed, an excellent way to learn Clojure is to study the source definitions of its API functions. This advice works better for learners who know Java, which I don't. I sometimes think that, if I were to teach a "Clojure Programming" course, I

Re: What is this function?

2012-10-09 Thread Larry Travis
Mark, Andy, Tassilo: Very helpful, gentlemen. You are kind and skillful tutors. Thank you much. --Larry -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members ar

Re: What is this function?

2012-10-09 Thread Larry Travis
Pursuing the thinking behind my original comment, I challenged myself to see how many ways I could write a function equivalent to list* without using _spread_ (assuming I had the full Clojure API available to me -- which, of course, the author of list* did not have). Here are four ways: *(def

Using functions from Java packages

2012-12-16 Thread Larry Travis
It almost certainly has something to do with my abysmal ignorance about things Java, but I don't understand this difference: (1) user> (map Math/sqrt [5 6 16]) Unable to find static field: sqrt in class java.lang.Math [Thrown class java.lang.RuntimeException] (2) user> (map #(Math/sqrt

Re: Using functions from Java packages

2012-12-16 Thread Larry Travis
Thank you, gentlemen. Jim and Luc, your answers are both helpful. Luc's answer illustrates why a Java tyro often has problems understanding Clojure. Somebody like me who is trying to master Clojure, having come to it via a language path that doesn't include Java, needs a prerequisite crash cour

How can I make this kind of error message more useful?

2012-01-03 Thread Larry Travis
I have been solving Clojure problems now for many months and can no longer exactly be considered a Clojure NOOB, but I still have an awful lot to learn about Clojure. One thing that has caused difficulties from the beginning is that I don't know Java and don't know how to exploit the Java eco-

Re: How can I make this kind of error message more useful?

2012-01-03 Thread Larry Travis
:5045) the REPL line which resulted in the error message was 15392, not 5045. So where does the 5045 come from? --Larry On 1/3/12 12:59 PM, Meikel Brandmeyer wrote: Hi, Am 03.01.2012 um 18:24 schrieb David Nolen: On Tue, Jan 3, 2012 at 12:09 PM, Larry Travis wrote: But my error messages are

Why won't leiningen install for me?

2011-01-22 Thread Larry Travis
ut I don't think I would know what to do with it if I could! I am a Java tyro (who knows some other lisps reasonably well) trying to use clojure under Mac Os X and Emacs, but I am having a lot of problems getting clojure to run conveniently in that environment. Thanks for your help. -

Re: Why won't leiningen install for me?

2011-01-25 Thread Larry Travis
tps to be supported and then things worked fine. I could dig up my notes from when I did it if you need more information. Cheers, John On Jan 21, 4:49 pm, Larry Travis wrote: I get the following when I try to install Leiningen: --- larrytravis$ lein-install.sh self-install Downloading

Re: Why won't leiningen install for me? (NOW IT DOES!)

2011-01-25 Thread Larry Travis
You guys are great! As my dad used to say when he had been greatly helped: Each of you is a scholar and a gentleman. I admire your expertise. You each had knowledgeable and quite helpful suggestions. I ended up using Alex's ideas for getting the Leiningen installation process to avoid Macport

Question about the Clojure load-file command

2011-03-12 Thread Larry Travis
":867" to the file's name and then tell me that the changed name is an unresolvable symbol? Thanks for any advice any of you might have. I hope the question isn't impossibly dumb. --Larry Travis -- You received this message because you are subscribed to the Google

Re: Question about the Clojure load-file command

2011-03-12 Thread Larry Travis
, Ken Wesson wrote: On Sat, Mar 12, 2011 at 7:49 PM, Larry Travis wrote: I'm having trouble getting the load-file command to work in a Clojure repl. On some files it works and on some it doesn't. Here is an example of its not working: I do: (load-file "/Users/larrytravis/AquaFile

Re: Question about the Clojure load-file command

2011-03-13 Thread Larry Travis
start can quickly be caught and corrected, but I suspect that in this case I made such a false start and didn't fully correct for it. --Larry On 3/12/11 9:09 PM, Ken Wesson wrote: On Sat, Mar 12, 2011 at 9:46 PM, Larry Travis wrote: Ken: The cause of my difficulty indeed was a corr

Re: Clojure load-file command (+ Aquamacs, Bluefish)

2011-03-14 Thread Larry Travis
On Sun, Mar 13, 2011 at 1:51 PM, Larry Travis wrote: Ken: Your question is an interesting one. My answer may serve as a word to the wise: I do my Clojure source-code editing in Emacs (actually Aquamacs, but the difference is not important for what I am saying here). As any Emacs user knows, when