#clojure log - Nov 27 2008

The Joy of Clojure
Main Clojure site
Google Group
IRC
List of all logged dates

0:06 quuxman: jshen: I had the same problem

0:07 jshen: I gave up eventually. That was also the advice of a couple other people who were around here

0:07 jshen: hehe

0:07 quuxman: jshen: rlwrap is a little better than nothing

0:07 jshen: i'll just jump to getting oen of the emacs modes working

0:08 quuxman: jshen: yeah, think that's what most people do. I'd be interested to hear how you get SLIME working

0:09 jshen: is that a pain point for a lot of people?

0:09 quuxman: I don't know. I didn't try very hard

0:12 jshen: did you see this? http://en.wikibooks.org/wiki/Clojure_Programming#Emacs_.2F_Slime_Integration

0:12 I'm going to start there, but not tonight

0:13 mattrepl: jshen: let me know if you run into any hitches. the one gotcha is if you want extra items on the classpath, you need to set those before the requiring of swank-clojure-autoload.el

0:14 jshen: thanks

1:04 yanbe: A lisp compiler for the AVM2. http://github.com/aemoncannon/las3r/wikis/home

1:05 perhaps related to this channel

3:18 Lau_of_DK: Top of the morning gents

9:05 mmcgrana: Is this a reasonable / the best way to do a trailing optional arg? : (fn [req-arg & [opt-arg]] (do-something req-arg opt-arg)) I'd prefer not make a second definition with reduced arity.

9:32 Lau_of_DK: mmcgrana: How else would you do it?

9:34 mmcgrana: I couldn't immediately think of one - that was my question.

9:34 I was just wondering because I think of & as a "vararg" operator not an "optional arg" operator

9:35 but this works for me i guess

9:35 Lau_of_DK: I cant think of a better way :)

9:35 mmcgrana: het Lau_of_DK I actually have a another question about *warn-on-reflection* - you ever use that?

9:36 *hey

9:36 Lau_of_DK: I'd phrase it as: Ive disabled it :)

9:36 mmcgrana: ok

9:46 duck1123: warn on reflection is good if you're into premature optimization

9:49 Lau_of_DK: duck1123: news to me, can you explain what you mean ?

9:50 duck1123: # "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil. Yet we should not pass up our opportunities in that critical 3%." - Donald Knuth

9:52 notallama: this reminds me: how do you do profiling, when you know something is going slow? just wrap things in a time block until you find it?

9:53 duck1123: notallama: You have all the java profiling tools at your disposal

9:53 Lau_of_DK: notallama: you just hook up the profiler, run the program and read the results :)

9:53 Netbeans JFluid works fine with Clojure

9:54 duck1123: of course, I say this after just getting done profiling two different versions of a function with time

9:56 notallama: these java tools confuse me. : ( i suppose i'll have to learn them eventually, though.

9:57 mmcgrana: Lua_of_DK: is it possible to use JFluid outside of / without Netbeans? I've used YourKit with good results during my free trail period but can't really pay for a license at this point...

9:58 Lau_of_DK: Yes JFluid _should_ be able to standalone, I just downloaded the integrated version because it was so easy to fetch from the plugins list

9:58 @ mmcgrana

10:00 mmcgrana: ok cool, will investigate.

10:00 Lau_of_DK: thanks

10:00 Lau_of_DK: notallama: It should be TOO confusion. You start your repl with certain paramters. Like for the profiler you start an agent, which stops execution until the profiler connects. So in the end, it makes sense

10:02 notallama: and for the debugger, you dont have to wait for anything, start with appropriate paramters, and code away to your hearts content. When you need it, just attach the debugger to localhost:8888 or whatever port you picked when starting the repl

10:05 notallama: i'm mainly thinking of jswat. it was situations where there's menus and windows /everywhere/. i got it hooked up, and found out how to set a breakpoint, though, so i'm probably not too far grom getting it to do something useful.

10:06 duck1123: has anyone here used jdee for emacs?

10:06 I downloaded it, but haven't gotten around to setting it up

10:07 Lau_of_DK: duck1123: jdee?

10:11 duck1123: clojurebot: jdee is http://jdee.sourceforge.net/

10:11 clojurebot: You don't have to tell me twice.

10:12 Lau_of_DK: hiredman: Maybe you should let cb pick on questions without the clojurebot : prefix

10:12 duck1123: fsbot uses the ,keyword syntax

10:13 Lau_of_DK: duck1123: oh... a glorified java-mode :)

10:13 duck1123: Lau_of_DK: it says it has a debugger, so I'm thinking of giving it a try

10:13 timothypratley: what's a good way of of managing shared access (between threads) to a single stream?

10:13 Lau_of_DK: duck1123: looking forward to reading your report

10:14 timothypratley: you mean besides refs ?

10:14 timothypratley: hmmm I assumed ref would only control access to the stream object

10:14 but writting to the stream would still conflict

10:16 ooo maybe an agent

10:16 Lau_of_DK: Commute the reads to the stream, have an agent atomically write out the stream and clear the buffer... how about that ?

10:20 timothypratley: oh... wait commute solves the problem without agents entirely though doesn't it? Because "write" can be the function, and it will be contained in the transaction

10:21 I hadn't thought of that

10:26 Chouser: You might want to use a clojure.lang.PersistentQueue in your collecting ref.

10:35 notallama: anyone know how to set up a classpath properly? i went into my clojure-extras clojure script, and i tried adding some jars and dirs to the path, but no luck. it can't seem to find anything i add, yet it can find jline and clojure.

10:35 i just put :path.jar at the end of the stuff on the -cp flag.

10:36 Chouser: notallama: that should be all it takes.

10:36 java -cp foo/bar/clojure.jar:bing/bang/other.jar clojure.lang.Repl

10:37 notallama: are you on Windows?

10:37 notallama: linux

10:38 timothypratley: Chouser: thanks for the tip re PersistentQueue, can you expand a bit on what you mean?

10:39 Chouser: well, that should do it. Then at the REPL you should be able to refer to a class name from the jar: user=> com.fancypants.Other

10:39 timothypratley: you used the word "stream" which suggests you might have thread pushing items onto one and of the queue, and some other thread (or threads) pulling them off the other end. thus a queue.

10:40 timothypratley: yup, that's exactly right! :)

10:41 Chouser: so you can have a ref pointing to a persistent queue, push onto it inside transactions, pop from it inside transactions, and you should be all set.

10:41 timothypratley: yup, that's perfect thanks.

10:42 Chouser: on the other hand ... do you want these threads to block on empty queues?

10:42 rhickey: Chouser: exactly

10:42 most usage of queues requires workflow

10:43 * Chouser warms up the java.util.concurrent docs.

10:43 rhickey: that's why I haven't exposed PersistentQueue yet - I'm afraid of people building polling systems on top of refs

10:44 that's also why java.util.concurrent wrappers are on the way - not enough people know about them

10:44 but I consider them an important complement to Clojure's facilities

10:44 notallama: i think i tracked down the problem i was having: it doesn't seem to like "~" in the classpath.

10:44 Chouser: rhickey: I just saw clojure code that was doing busy polling on a UI events and a IO events.

10:45 rhickey: Chouser: aargh

10:45 Chouser: It's hard to save programmers from themselves via langauge features.

10:45 rhickey: Chouser: we'll see, when there are queues in the API and examples using them

10:46 But yeah, polling sucks and everyone should know that

10:46 timothypratley: in my particular case I do want to block on empty queue, does that put me in the bad category or the good category?

10:46 Chouser: yeah, I guess that's the best hope -- make the right way so easy and obvious that nobody bothers trying the wrong way.

10:46 rhickey: Chouser: right

10:46 timothypratley: great!

10:47 Chouser: timothypratley: it means a PersistentQueue ref is not right for you.

10:47 rhickey: timothypratley: look at java.util.concurrent.BlockingQueue

10:47 timothypratley: damn.

10:47 ok will do

10:47 rhickey: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/BlockingQueue.html

10:47 Chouser: timothypratley: the fact that you know you want to block is a great sign. :-) You'd find yourself stuck after a while trying to use the PersistentQueue.

10:49 hm, and no dosyncs around 'put's or 'take's, right?

10:49 those count as side-effects.

10:50 rhickey: Chouser: right, find out you have work, take and do it in a transaction, maybe put after transaction or via action sent in transaction

10:51 queues are I/O

10:51 * rhickey needs to get back to IO and LFE model...

10:52 Chouser: non-persistent queues are I/O

10:52 rhickey: Chouser: yeah, I wish they had different names, the workflow queue and the data structure queue

10:52 Chouser: LFE? Is that the io/seq thing from the Haskell slides?

10:53 rhickey: Chouser: yes, cgrand did that nice write-up and I never got back to him

10:54 I implemented about half the Haskell system exactly in Clojure - I found it extremely cumbersome and unlikely to be used as is in Clojure

10:54 timothypratley: just to humour me, would this be a terrible way: create an agent which is the stream. I send the stream agent a "send message" function which returns the stream itself. From my very virgin understanding of agents they effectively queue up function calls that transition states (though here I would just be side-effecting). [in reality I'm going to pursue the blockingqueue as I expect to later want to monitor the queue etc]

10:54 rhickey: Too much effort to make iterators chainable, lots of rules to follow in your implementation

10:56 Chouser: Just to make sure I was understanding it despite the Haskell syntax, I tried implementing what I thought were the important parts for the half or so of the slides. I was intruiged at how different my code was from cgrands.

10:56 ...mainly having to do with what I thought were the important features.

10:56 But differing from cgrand is not a great sign, so I'll have to go back through it again at some point.

10:57 rhickey: cgrand based his work on an earlier paper (one I saw Oleg present at LL3), not the slides I mentioned, which is the most recent state of that earlier work

10:58 The earlier paper tried to show that you could turn any enumerator into a seq/stream, but in doing so you negate the benefits of LFE in controlling resource lifetime

10:59 Chouser: timothypratley: hm, so your "work queue" would be the agent's own queue and the items of work would be action closures.

11:00 rhickey: the newer work instead focuses on making both iterators and enumerators composable so you don't convert to streams/seqs, but cgrand did to implement multi-collection map

11:00 Chouser: rhickey: ah! ok, that explains some of the different emphasis in cgrand's work.

11:01 timothypratley: That would limit you to a single consuming thread, but other than that I can't think of why that wouldn't work.

11:04 rhickey: But the interfaces involved to/from the iterators are pretty complex - possibly empty streams, done states with stream remainders, continuation states with fns of streams - ugh, no wonder it takes 90 slides to explain

11:05 Chouser: yes, agents are single-consumer queues

11:14 Chouser: clojure seqs are comparatively simple and tidy.

11:14 But resource management is hardly ever simple or tidy, so I guess it's to be expected.

11:18 rhickey: Chouser: right, I want something as simple for io

12:06 notallama: is there a "standard" way to name two-word namespaces? dashes? camel case? underscores?

12:08 Chouser: dashes

12:08 which become underscores in file and class names

14:05 AWizzArd: Anyone here who uses Tomcat and/or Jetty?

14:05 blackdog: jetty

14:06 AWizzArd: same here

14:06 did you also use it in combination with Clojure?

14:06 blackdog: yes,

14:06 i do servlets returning json

14:06 that's it really, no jsp

14:06 AWizzArd: I want to get it running with Rife

14:06 blackdog: don't know what that is

14:07 AWizzArd: One of the (if not the) most powerful webapplication development frameworks available.

14:07 blackdog: ah

14:08 i'm done with web frameworks, i do all my rendering on the client

14:08 AWizzArd: Yes, I will have to think about that as well.

14:08 Still, there is a lot of stuff to do.

14:09 Validation of each and every input field. Continuation support, so that the user can go back and forth, scaffolding, etc

14:10 blackdog: if you just return json then you have a very large selection of client side tools, jquery/dojo etc

14:10 which can provide a lot of the scaffolding

14:10 AWizzArd: Yeah, I am looking at using dojo as well.

14:36 blackdog: AWizzArd, you need to do ./run test.clj

14:37 AWizzArd: re

15:41 nolbat: how does java make everything so complicated? im trying to translate paul grahams raytracer to clojure. i use javax.imageio but i dont get how to just create an image pixel for pixel.

15:41 imagewrite has like 10 different donkeymethods

15:41 AWizzArd: :-)

15:41 Java is the modern assembler

15:42 If Java is your only tool then every problem looks like a thumb.

15:52 nolbat: no matching ctor found = constructor

16:09 seriously can someone help me with this.

16:10 (new ImageReader "C:/users/saftarn/desktop/raytracing.jpg")

16:10 doesnt work no mathcin constructor

16:10 i have to call some ImageReaderSpi wtf

16:10 who writes the javax libs? is it Sun? becaus eif not even the creators of the language can write decent code...

16:11 pdoubleya: nolbat: do you have a working sample in Java? i worked with the imageio apis in the last...hmm, over a year ago, may have some sample code, at least for writing images to a file

16:12 walters: nolbat: ImageReader looks like it's an abstract class

16:13 nolbat: yeah i dont know java evry well, abtsratc this implements extends that.

16:14 walters: nolbat: it looks like you may want just ImageIO.read(new File("C:/users/saftarn/desktop/raytracing.jpg"))

16:14 nolbat: seems like Java was a contribution to an obfuscated C contest then some mistook for a real programming language

16:15 pdoubleya: nolbat: yeah, the imageio lib is pretty complex, from what i recall...but it was aimed at people who need full control over many different image formats...i found it a hassle as well

16:18 nolbat: java.lang.ClassNotFoundException: ImageIO.read (NO_SOURCE_FILE:1)

16:18 (import '(javax.imageio ImageIO ImageWriter ImageReader))

16:18 how do i import File=

16:18 File?

16:19 walters: (import '(java.io File)) looks like

16:20 so all together: (ImageIO/read (File. "/usr/share/icons/abiword_48.png"))

16:20 worked for me

16:20 but i don't actually know Clojure, only Java so take it with a grain of salt =)

16:29 nolbat: ah nice

16:32 AWizzArd: I would really like to know how many of you are actually coming from Java, from CLand from something else.

16:34 kotarak: AWizzArd: coming from Scheme, Perl, Ruby, C, pick one.... :)

16:44 nolbat: have minor java knowledge(tried and hated it). know Python very well adn scome Scheme, haskell, C, little C++

16:46 wanted to learn lisp more and scheme and cl didnt have a practical platform.

16:48 so: ImageIO.write(rendImage, "png", file);

16:48 becomes what ? (ImageIO/write rendImage "png" file) ?

16:48 rotty: walters: hi there! didn't know you were into lisp :-)

16:49 nolbat: Does CLojure use Javas green threads?

16:49 walters: hey rotty! well, clojure has a lot of interesting ideas I think; the readonly data structures with structural sharing, the STM etc. I'm not totally sold on Lisp, but I'm pretty sure some of Clojure's DNA is going to start appearing in new languages at least

16:49 (and existing ones)

16:50 nolbat: OpenJDK hasn't used green threads since the mid 1990s

16:51 rotty: yeah, clojure is pretty interesting. I've yet to try it -- still sticking with Scheme so far...

16:51 * rotty is pretty sold on Lisp :-)

16:53 notallama: i know a bit of java, c, scheme, and a tiny bit of python (i found python irritating.) i have not really written much of anything though. just school type stuff. clojure's by far the nicest, though.

16:54 AWizzArd: Not all are in the lucky position to be paid Clojure developers *g*

16:56 nolbat: notallama: what did you find annoyin about python?

16:57 * rotty thinks python is pretty decent as far as imperative, statement/expression-split languages go

16:58 notallama: i think it was the lambdas. they set my brain in scheme mode, but they're not really the same as scheme lambdas. it's probably somehting i'd get used to if i used it more.

16:59 * walters really hates python's lack of "private", and the way properties and functions are just stuck in a mutable hash table that every object carries around

16:59 kotarak: the python lambda doesn't deserve the name...

17:00 nolbat: so whatever

17:00 they do everything i need

17:00 big deal

17:03 notallama: it's probably the same idea as trying to use java style in scheme. it just doesn't work well.

17:04 nolbat: but you can do most of what u need wiht python lambdas

17:05 notallama: with c and java, i had classes to figure out what idiomatic code looks like. with scheme, there's sicp. with python, i just wasn't sure what i was doing. i'm not saying python is bad, just that my first attempt at it didn't go well.

17:06 nolbat: >>> map(lambda x: x**2 if x < 5 else x**3, range(10))

17:06 [0, 1, 4, 9, 16, 125, 216, 343, 512, 729]

17:07 AWizzArd: walters: it is not dramatically different in Clojure. There you also have no "private" data. And you will store lot's of your data in hash maps :-)

17:09 walters: AWizzArd: right, but Clojure doesn't claim to be an object oriented system, which is fine; I agree for concurrency the readonly data structures make more sense, but object orientation (without the need for concurrency) makes a lot of sense in other problem domains like GUIs

17:11 notallama: clojure can do oo now, with gen-class. has private methods too.

17:12 AWizzArd: we want to try to avoid that as much as possible

17:12 notallama: oh? how come?

17:12 hiredman: (doc defn-)

17:12 clojurebot: same as defn, yielding non-public def; arglists ([name & decls])

17:13 hiredman: speaking of private

17:14 AWizzArd: notallama: because Clojure is a functional programming language and I personally believe that the functional paradigm has more use in many cases

17:15 It is declarative.. you say *what* you want to do, and not *how* to do it.

17:17 nolbat: i wrote a basic OO-system in clojure, it is not hard

17:17 but i dont need it

17:17 just using Maps and multimethods works fine

17:17 notallama: i don't really see where the conflict is. you have a function that maps some set of objects onto some other set of objects.

17:19 nolbat: which conflict?

17:21 notallama: AWizzArd was saying that we want to avoid oo with gen-class because functional is more useful (i interpreted it that way, anyway). so your question is pretty much a repeat of mine.

17:22 nolbat: ah

17:22 i still havent figured out how to write to an mage

17:23 like in Python I just look these things up and then do it. with java...

17:25 notallama: did you look at the compilation section on the clojure site?

17:27 nolbat: i never have to throw and catch checked exceptions n Clojure?

17:29 AWizzArd: nolbat: we want to go away from telling the computers how to do things. The direction should be: saying what we want and let them figure out how to do it.

17:30 to some extent a functional programming style is exactly that. When you write a fibonacci function you have not programmed anything. You wrote down the mathematical definition.

17:35 kotarak: (doc refer)

17:35 clojurebot: refers to all public vars of ns, subject to filters. filters can include at most one each of: :exclude list-of-symbols :only list-of-symbols :rename map-of-fromsymbol-tosymbol For each public interned var in the namespace named by the symbol, adds a mapping from the name of the var to the var to the current namespace. Throws an exception if name is already mapped to something else in the current namespa

17:35 notallama: right. but don't you still need the computer to have some description of what the function is operating on? (i'm aware that you can construct natural numbers from lambdas, but it's certainly helpful to have first class integers. why not extend that to objects?)

17:35 nolbat: (defn writeFile [image format path]

17:35 (ImageIO/write image format (File. path)))

17:35 works

17:36 AWizzArd: notallama: of course, a program without side effects makes no sense and is very boring

17:37 I just want to minimize and centralize them

17:38 rotty: btw, is there any chance that clojure might get call/cc at some point in the future?

17:38 AWizzArd: You can do that with threads

17:38 notallama: i don't know a lot about call/cc, but trampoline seems like it's getting close.

17:39 rotty: notallama: I think trampolines are about proper tail calls

17:39 AWizzArd: how so?

17:39 AWizzArd: and well, you could implement them yourself rotty, you have macros

17:40 threads and their environment

17:41 nolbat: anyway good with imageio? i can open a file and write to another file but i dont get how to manipulate it, it is funny how for all its documentation, static typing JAVA stillf ails to get to the point and tell wtf a method is actully doing. it just passes classes here and there

17:41 AWizzArd: rotty: do you know http://www.paulgraham.com/onlisp.html already? It's maybe the best book about macros in Lisp. Paul Graham implements continuations in there. You can download the book (legally) for free there.

17:42 nolbat: I know how you feel.. it seems the authors wanted to put in everything at an extremly fine granularity

17:43 notallama: rotty: it is for that, but it works by passing a function and an environment around. i just have a hunch that it's about 2 macros away from call/cc.

17:44 walters: nolbat: it looks like you need to call createGraphics to get a graphics context; then there are a bunch of drawing methods on that

17:45 drewc: notallama: my pet project is an implementation of delimited continuations for clojure.

17:45 walters: nolbat: or if you want to get/set pixels, you can call getRaster

17:46 * rotty goes reading the onlisp chapter on continuations

17:46 drewc: trampolining was the technique i was playing with prior to it being included, and it is indeed a good start.

17:47 nolbat: walters: ah iw ant toget/set pixels , thanks

17:47 drewc: rotty: that's honestly not the best introduction to either call/cc or on how to implement it IMO.. but it is somewhat accessible.

17:48 rotty: just don't go getting the idea that his method is the only, or the best, way to hack up call/cc on top of a lisp that doesn't offer it :)

17:48 nolbat: what d i call getRaster on? i cant find the method

17:49 walters: nolbat: BufferedImage

17:50 kotarak: Does anyone experience problems with the latest SVN?

17:50 In particular with use/require?

17:58 nolbat: im a bit unsure on the whole how to use JAVA from clojure. if i pass a BufferedImage to a funciton and want to do getRaster on it, whats it he correct way.

17:58 kotarak: (.getRaster your-buffered-image)

18:21 nolbat: http://java.sun.com/javase/6/docs/api/java/awt/image/WritableRaster.html

18:25 so i have my raster and want to do setPixel, how do i supply an areay?

18:25 is that array meant to rep the color?

18:28 #<ByteInterleavedRaster ByteInterleavedRaster: wid

18:28 is what i get but i should get WritableRaster

18:29 and then it says no setColor for ByteInt...Raster

18:30 walters: nolbat: http://clojure.org/java_interop#toc26

18:47 nolbat: one thing i dont get with the clojure mentality is. lets say i want the equivalence of an Image-class, how would abstract that in CLojure?

18:48 i mean thats a thing where i normally think of some sort of entity/object with attached methods

18:48 AWizzArd: nolbat: a structured map with some functions operating on it, in it's own namespace

18:50 so instead of having a class person with the fields name, age, address you will have a (defstruct person :name :age :address)

18:53 nolbat: ah i see

18:54 can i check the type of a java-object at runtime?

18:55 yes class

18:56 walters: nolbat: (.getClass foo)

19:00 nolbat: so if i want to collect a bunch of clojure-functions for image-stuff. should i put it in its own namespace?

19:01 sun.awt.image.ByteInterleavedRaster is what i get but according to the docs i should get WritableRaster. anyone could guess why?

19:03 lisppaste8: nolbat pasted "raster-problems" at http://paste.lisp.org/display/71140

19:06 walters: nolbat: groovy:000> WritableRaster.class.isAssignableFrom(ByteInterleavedRaster.class)

19:06 ===> true

19:06 (i don't know how to refer to class literals in clojure, so using groovy syntax)

19:08 nolbat: i dont know java to well so what does that mean? how do i go from Byteratser to Writableraster?

19:09 walters: the ByteInterleavedRaster *is* a WritableRaster, it subclasses it

19:11 nolbat: ok, but t doesnt have that methods

19:12 wait wtf

19:12 setPixel it should be wtf was i thinking

19:12 still deosnt work though :)

19:13 Chouser: user=> (isa? sun.awt.image.ByteInterleavedRaster java.awt.image.WritableRaster)

19:13 true

19:13 nolbat: java.lang.IllegalArgumentException: No matching method found: setPixel for class sun.awt.image.ByteInterleavedRaster (NO_SOURCE_FILE:0)

19:14 walters: as for how you set the pixels, it looks like the format depends on samples, and it isn't immediately obvious to me how it works

19:14 Chouser: nolbat: that error often means the argument types are incorrect.

19:14 walters: i haven't actually done any awt or swing since the late 1990s, and am in fact right now actively working to replace both of them =)

19:14 nolbat: anything wrong with them? arent they the most used ones in java?

19:18 walters: nothing strictly speaking wrong with them, particularly if you care about cross platform

19:18 Chouser: nolbat: setPixel takes an array of int, float, or double. into-array cannot produce any of those.

19:27 (doc int-array)

19:27 clojurebot: Creates an array of ints; arglists ([size-or-seq] [size init-val-or-seq])

19:32 nolbat: but is int-array a java-array?

19:32 or i ahve to do into-array (int-array?

19:33 what does it mean when a JAVA method returns NIL? java method retuns nothing? just does its sideffect?

19:33 so it workd?

19:34 Chouser: seems likely, yes.

19:34 yeah, setPixel returns void, so if you should expect nil

19:34 no exception is a good sign.

19:37 nolbat: im learning image analysis, clojure seem to be good because it connects to java, allows for easy parallell processing. is there an interface to matlab?

19:37 would it possible to create?

19:38 if i want to create an imaging-module, i then put it in its own namespace

19:38 (in-ns 'imaging)

19:38 but when i import in that fle i get import not recognized or soemthing

19:40 should i import to the namespace or soemthing?

19:51 Chouser: in a file, use 'ns' instead of 'in-ns'

19:53 and namespaces ought to have at least one package-part

19:53 nolbat: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol (imaging.clj:0)

19:53 package-part? i thought that was the name-space

19:56 #<imaging$get_image__2587 imaging$get_image__2587@1332109>

19:56 (ns imaging)

19:57 Chouser: (ns nolbat.imaging (:import (java.awt.image WritableRaster)))

19:58 nolbat: you mean imaging should be part of a package?

19:58 why?

19:58 Chouser: namespaces map to class names, and Java class names should be in a package.

20:51 nolbat: using setPixel should be enough right?

20:51 on a Raster

20:52 Chouser: enough for what?

20:52 lisppaste8: nobalt pasted "writing-image" at http://paste.lisp.org/display/71145

20:52 nolbat: im trying to write a line on a white image.

20:57 Chouser: I don't know the APIs involved at all. you might want to try translate a Java example to begin with.

21:08 Flox_: nolbat: If you want something interactive accessible from Clojure, you might be interested in Fiji (http://groups.google.com/group/clojure/browse_thread/thread/15f566f12cc485a4/8b2a5b1a0dc61c87?lnk=gst&q=imagej#8b2a5b1a0dc61c87).

21:08 That way, you would have access to all existing ImageJ image analysis plugins from Clojure...

21:09 nolbat: cool

21:10 wow cool exactly what iw as thinking about creating :)

21:14 Flox_: nolbat: Don't look at what Albert Cardona has achieved using ImageJ. It will make your eyes pop out...

21:15 rsynnott: presumably the JVM would make returning multiple values similar in perfirmance to using a vector, anyway

21:16 Flox_: I can't wait to see the first multithreaded image transformation and analysis plugins appear - thanks to Clojure!

21:17 Good night!

21:23 nolbat: Flox_: thats what im want to learn, image processing si perfect for parallellism(embarassingly parallell)

22:16 ok i have a java-version fo what iw ant to do now. this is good btw cuz im learning java at the same time which you kind of have to no matter what you think of it right, its seems to be everywhere?

22:17 but my main problem in mky head is

22:17 java is sideffectful, clojure is functional

22:17 so when oing with sideffects im a it confused here

22:19 lisppaste8: nolbat pasted "writing to image" at http://paste.lisp.org/display/71148

22:19 nolbat: someone can have a look?

22:24 plz

22:31 noone there?

22:32 http://paste.lisp.org/display/71148

22:32 (for [x (range 300 300)]

22:32 (for [y (range 300 300)]

22:32 (.setRGB buffered-reader x y rgb-color)))

22:32 something wrong with that?

22:35 durka: i don't really know clojure yet but the range in the paste looks a little strange

22:35 nolbat: am i that annoying? everyone put me on ignore?

22:35 oh well lol

22:35 durka: and different from the range you just typed

22:35 nolbat: but that isnt the problem it still doesnt work for 200 300

22:37 durka: hmm

22:38 lisppaste8: fdg annotated #71148 with "fdgfdg" at http://paste.lisp.org/display/71148#1

22:38 nolbat: wait i might see

22:38 no it should be ok

22:39 ah wait

22:39 no that should be ok too :(

22:42 or somehow the buffer im updating isnt the one im writing to the file?

22:44 durka why does the range in the paste look strange?

22:45 durka: well the one in the annotation doesn't

22:45 but range(100 200) doesn't look like lisp

22:45 nolbat: nah i hcnaged that

22:46 but as i see it i do exactly like the JAVA version

22:48 setRGB is void

22:48 does for need a return value?

22:59 imaging> (.getRGB (get-image rt) 10 20)

22:59 -1

22:59 imaging> (.getRGB (set-pixel (get-image rt) 10 20 212) 10 20)

22:59 -16777004

22:59 -16777004 is also the value iget in java

22:59 but also for 112 or 212 as setRGB-value

23:05 dlonki: ok now i can set one pixel

23:05 it must be something with the looping

23:06 what does for do exactly? form some sort of clouse or soemthing where the image inside is something else than the image outside?

23:16 ok so i can do change one pixel and save it

23:16 i cant use map and ic ant use for

23:16 maybe loop recur?

23:24 wow faakkking finally

23:24 it worked with looop recur

23:24 map and for-comprehensions dont work, i have to pass along the picture

23:26 notallama: what was it you were trying to do?

23:26 dlonki: editing a picture

23:27 BufferedImage

23:27 and then give it a range of pixels to change to a specific color

23:27 lisppaste8: ak annotated #71148 with "loop-recur works!" at http://paste.lisp.org/display/71148#2

23:28 dlonki: that took several hours lol

23:28 notallama: that sounds lime something you could do with doseq and for.

23:28 dlonki: well for didnt work, maybe i was doing it wrong

23:28 notallama: what was your for?

23:29 for is lazy, so if you were trying to do side effects with it, that's your problem.

23:30 dlonki: aha

23:30 u can see it all^^

23:34 notallama: what's vs?

23:34 dlonki: oh i changed to vector-pairs

23:34 [[1 2] [2 4]] etc

23:34 or (map vector (range 100) (range 100 200))

23:35 im trying to do a doseq but dont quite get it

23:38 notallama: (doseq [[a b] vs] (set-pixel image a b color)) or something. it binds to the first thing in the seq, and does the body, then the second, etc.

23:40 the syntax might be different depending on what version you're using. the old one didn't have the square brackets around the binding forms.

23:53 dlonki: ah yes doseq is elegant

23:53 what about laziness make for not work?

23:54 notallama: only the first thing in the seq gets evaluated.

23:54 the rest of it waits for something to call "rest" on the seq.

23:56 dlonki: so i should what? is there some way force it?

23:58 danlei: clojurebot: dorun?

23:58 clojurebot: Titim gan ?ir? ort.

23:58 danlei: (doc dorun)

23:58 clojurebot: When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. dorun can be used to force any effects. Walks through the successive rests of the seq, does not retain the head and returns nil.; arglists ([coll] [n coll])

Logging service provided by n01se.net