Re: Beginner: let with Java object

2017-05-26 Thread Christopher Howard
'ClassCastException java.awt.image.BufferedImage cannot be cast to > clojure.lang.IFn tutorial.core/-main (core.clj:11)' would lead me to > look for things like '(img)' where the object ends up in call position > of the s-expression. > > On Fri, May 26, 2017 at 11:54 AM Chri

Beginner: let with Java object

2017-05-26 Thread Christopher Howard
When I run tutorial.core> (let [img (new-image 32 32)] (set-pixel img 10 10 cyan) (show img)) from the REPL, this returns a javax.swing.JFrame object, and displays the frame and image as expected. However, if put the same in (defn -main "Generates image." [& args] (let [img (new-image 32 3

restarts

2014-06-19 Thread Christopher Howard
Does Clojure have restarts or continuable-errors like in CL? Or something similiar? If not, is that something that could be implemented some how? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups

macro question

2014-06-16 Thread Christopher Howard
Disclosure: I'm rather fascinated with macros (the things they are supposed to allow us to do), but I'm still rather mystified about how they actually work. It seems like every time I try to write one, it rarely behaves anything like I expect. Question: Is there any obvious problems with this seem

using "hidden" parameters?

2014-06-13 Thread Christopher Howard
This might be kind of perverse, but I was wondering if it was possible to write a function or macro that takes "hidden parameters", i.e., uses symbols defined in the scope of use, without passing them in explicitly. For example, function "next-number" takes hidden parameter "x", so => (let [x 12]

arguments passed to a macro

2014-06-05 Thread Christopher Howard
Is there a trick for "pre-expanding" some of the arguments passed to a macro? Say you wanted to do this code: (def swing-imports '(javax.swing JFrame JButton ImageIcon JPanel)) (ns example.myprogram (:import swing-imports)) ... ns will complain that it can't find the "swing

seesaw: drawing text

2014-06-03 Thread Christopher Howard
Hi. In seesaw, how do you draw text to a graphics 2d object? I see in seesaw.graphics how to draw circles and lines and such, but want to draw a line of text. (I'm drawing on a canvas.) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this g

setting environment variables for all repls?

2014-05-14 Thread Christopher Howard
Hey all, I want (set! *print-length* 40) to be run each time I open "lein repl" (regardless of the project, preferably). I thought that is what the ~/.lein/init.clj file was for, but apparently not. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To

seesaw >> canvas >> paint

2014-05-02 Thread Christopher Howard
Suppose one is using seesaw, and wants to have a canvas with lots of images and whatnot drawn inside it. The github examples pretty well cover that. However, what if you want the paint function to behave differently depending on some data elsewhere? (For example, the canvas is supposed to be a visu

Elementary question about displaying images in an app

2014-04-24 Thread Christopher Howard
This is, I think, as much of a Java question as a Clojure question (I'm learning both at the same time). I'm writing a small desktop application, and I need to paint a few images in one part of the window (contained in PNGs). I'm looking through AWT/Swing/Graphics2D documentation, but I am a little

list all functions in namespace?

2014-04-04 Thread Christopher Howard
Is there some trick Clojure command to list all functions defined in a namespace? -- 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

Re: remove first?

2014-04-02 Thread Christopher Howard
On Wed, 2 Apr 2014 14:07:47 -0600 Timothy Baldridge wrote: > I don't know of anything built-in, but this should do the trick: > > (defn remove-first [f [head & tail]] > (if (f head) > tail > (cons head (lazy-seq (remove-first f tail) > > Timothy > > Thanks. This seems to wo

remove first?

2014-04-02 Thread Christopher Howard
Is there some like "remove", but only removing the first item found? Not exactly an incredibly hard problem, but with all this clojure stuff about collections and sequences, I'm not quite sure what the appropriate way is to implement it. -- You received this message because you are subscribed to

REPL: viewing data structures containing infinite lists

2014-03-31 Thread Christopher Howard
Is there some kind of "safe" function for printing representations of lazy, infinite data structures? I'm finding I like using them inside other data structures here and there. However, when I go to play around with things in the REPL, sooner or later my workflow is interrupted by 3 million charact

Re: using contrib functions

2014-03-31 Thread Christopher Howard
On Fri, 28 Mar 2014 20:06:59 -0700 Sean Corfield wrote: > BTW, where did you find the references to defadt and > clojure.contrib.types? Perhaps we can get the original references > updated so people aren't misled in future... > > Sean > I think it was this old StackOverflow post: http://stack

using contrib functions

2014-03-28 Thread Christopher Howard
Hi. --Insert here the usual caveats about being new to Clojure and Java.-- I wanted to try out this Contrib function describe on this page . How do I get that in my project? Trying to follow documentation, I

working with "multiple" return values

2014-03-28 Thread Christopher Howard
In Clojure, what is the easiest (cleanest) way to return "multiple" values from a function, in order to work with them immediately afterwards? In Haskell you can return a tuple, and pattern match the components into variables. Prelude> let (a, b) = (1 + 4, 2 - 1) Prelude> a 5 Prelude> b 1 IIRC, P

generators...?

2014-03-26 Thread Christopher Howard
Hi. I'm still fairly new to Clojure. I was wondering: What's the easiest way to make a generator (or something that would be as useful). In one application, I need something that will return a different color each time I call it - following a predefined list of colors, and starting over again at th