#clojure logs

2008-10-24

01:40burkelibbeyI get java.lang.UnsupportedClassVersionError when I do script/run in Compojure (I tried multiple source revisions).
01:40burkelibbeyHere's the stack trace: http://gist.github.com/19348 . I'm on OS X, and I'm largely clueless about Java. Am I missing something obvious?
01:43arbschtburkelibbey: are you running an older jvm than the version you compiled for?
01:45burkelibbeyoh, quite possible. I'll look into that
01:45burkelibbeywell... I have java version "1.5.0_16"
01:46arbschtwhat compiler version did you use (or what did it target)?
01:47burkelibbeyCompojure comes bundled with clojure. I'm not sure
01:47burkelibbeyI'll try the .jar that I know works on my system
01:48burkelibbeyoh well there we go. That worked. Thanks :)
01:55arbschtwas that just the clojure.jar? do the other included jars work?
01:57burkelibbeyI'm not sure actually. I thought it worked -- no more class version error. Now It's just spinning my processor.
02:04burkelibbeyhmm, works right away on my linux machine with 1.6.0_07. I probably just have to figure out some way to upgrade java in OS X >_>
02:11burkelibbeyOk. Upgrading java fixed my problems. For the logs: http://www.apple.com/support/downloads/javaformacosx105update1.html in OS X.
02:13arbschtburkelibbey: out of curiosity, where did you get compojure?
02:14burkelibbeyarbscht: http://github.com/weavejester/compojure/tree/master
02:16arbschtah, yes, it looks like the clojure.jar classes target java 6
02:16burkelibbeyCan't hurt to upgrade anyhow
04:57PupenoHello.
04:57PupenoAnybody knows how to build Enclojure from SVN?
05:03PupenoHello Lau_of_DK.
05:12Lau_of_DKHello Mr. Pupeno :)
05:24PupenoLau_of_DK: Everything all-right up north?
05:52Lau_of_DKPupeno, yes sir, it seems that everything is going just fine
05:53Lau_of_DKHow about the Neutral-land ?
06:32Lau_of_DKachim_p, Hi! :)
06:53achim_phi lau!
06:54arbschtheh cute, metadata makes it trivial to implement multisets atop sets
06:57arbschthttp://paste.lisp.org/display/69100
07:01arbschtequality semantics are lost though :(
07:03Lau_of_DKLooks.... Like Patchworj :)
07:03Lau_of_DKk
07:03achim_parbscht: why not just use a map? it would have correct equality
07:04arbschtachim_p: yes, I suppose any coll will do
07:05achim_pyeah, maps have fast key lookup times, though, should be as fast as a set
07:06arbschtachim_p: you mean a map in place of a set?
07:07achim_pyes, i'd just use the map you put inside the metadata instead of the set
07:08arbschtright
07:09arbschtI'm trying to see if the formal definition can be neatly expressed
07:10achim_pit would allow for a simple multiset-union: (merge-with + ...)
07:12arbschtlooks like the way to go
07:13arbschtthe 'underlying set' is then (set (keys multiset))
07:14Lau_of_DKdoes anyone here have a login to search the logs on this # ?
07:16achim_pLau_of_DK: a login?
07:17Lau_of_DKI know that n01se.net monitors the channel, but it requires a login to search
07:18achim_parbscht: yes, but that's probably rarely needed. maps behave much like sets, contains? etc. will work right away for (element->multiplicity)-maps: (contains? {:a 1} :a) => true
07:23arbschtachim_p: right
07:23Lau_of_DKShould this run? (filter #(every? alphanumeric? %) stream of chars
07:23Lau_of_DKWhen alphanumeric returns true if the charcode is in a certain range
07:23Lau_of_DKShouldnt that filter out alpanumericals?
07:27Lau_of_DKachim_p arbscht ? :)
07:28achim_pLau_of_DK: why the "every?"?
07:29Lau_of_DKThats a good question
07:30Lau_of_DKI honestly dont know why my logic works that way
07:30Lau_of_DKIt might be a defect in the brain :)
07:33achim_pis stream of chars a sequence of chars? filter decides on a per-item-basis: (filter even? [1 2 3 4])
07:34rhickeyfilter keeps, remove removes
07:34achim_pLau_of_DK: if your stream was a sequence of sequences of chars, you'd need "every?"
07:34Lau_of_DKYes I got that - Thanks :)
07:38Lau_of_DK(defn alpha-numeric?
07:39Lau_of_DKI dont quite get, why this throws the "Dont know how to create ISeq from Character"
07:39Lau_of_DKWhen you map/filter a stream, % is characters right? and (int \character) is an int ? which I numerically compare to another int
07:39Lau_of_DKIts the same with either map or filter
07:40Lau_of_DK(filter #(and ((> (int %) (int \a)) (< (int %) (int \Z)))) str))
07:41Lau_of_DK(should be <= >= I know)
07:41rhickeyjava.lang.Character.isLetterOrDigit
07:42rhickeyor whatever
07:42rhickeylots of predicates there
07:49achim_pLau_of_DK: how about (.replaceAll "ishjegoiwejf23iu2352j3b5342" "\\d" "") ?
07:50rhickeyuser=> (filter #(Character/isLetterOrDigit %) "abs23-54//:qwer")
07:50rhickey(\a \b \s \2 \3 \5 \4 \q \w \e \r)
08:07Lau_of_DKThanks alot Rich :)
09:48ChouserI guess I can't (set! *print-length* 100) in my user.clj?
09:49rhickeyChouser: I knew someone would ask that
09:50Chouseruser.clj seems to be used for various purposes. So far I've only used it to set up my repl with doc/introspection helpers.
09:51rhickeyIt really seems to be a repl setting, not a global one. Perhaps the repl could get defaults from somewhere
09:53Chouser~/.clojurereplrc
10:18Chouserok, I moved my personal repl settings to ~/.iclj.clj and created iclj shell script that uses rlwrap, my normal classpath, and include ~/.iclj.clj on the command line to clojure.lang.Repl
10:18duck1123I would like to see a setting that wraps the printing of seqs in an implicit (take *max-print-sequence* ...) so if I accidentally try to eval (constantly 1) I would only see a hundred or so. (with some sort of marker indicating the sequence was trunicated)
10:18Chouserthis gives me exactly the behavior I want
10:18Chouserduck1123: heh.
10:19Chouserthat's what we're talking about. *print-length* just went in this morning.
10:19duck1123ahh, that was before I logged in this morning
10:20duck1123excelent
10:20Chouserwasn't mentioned here, just on the google group.
10:20duck1123I'm behind on my mail
10:24j-dotChouser: I did essentially the same thing with a REPL-specific script that gets loaded by an iclj shell script. I wouldn't mind seeing something like this supported like user.clj is.
10:25ChouserI'm not sure. A distro- or OS-specific script might be just the right place to handle this kind of thing.
10:27duck1123http://github.com/dudleyf/clojure-bin loads a ~/.clojure script if it exists
10:27Chouserah, I love. I didn't have to make any changes to clojurescript to support *print-length*. Re-generate boot.js and it just works.
10:29ChouserI'm still trying to figure out the best way to handle passing command-line arguments through to the clojure app.
10:31j-dotyou mean passing them through a shell script on to clojure?
10:43Chouseryeah, with the -- on the java command line
10:44j-dotusing /bin/sh, appending "$*" to the end of the clojure command works for me
10:46jdzj-dot: putting that in double quotes would be wrong i think
10:46jdzwhat i think it means is that all the parameters will be passed as one
10:46jdzbut i avoid shell scripting like a plague
10:46j-dotso, my command is: rlwrap java -cp /path/to/clojure.jar:/path/to/clojure-contrib/src clojure.lang.Repl /path/to/my/repl-specific/initializer/script $*
10:46Chouserwell, I guess I'm thinking for shebang support. So foo.clj would have #!/bin/clj as its first line, and then running foo.clj --opt1 --opt2 would be like running java clojure.lang.Script foo.clj -- --opt1 --opt2
10:47j-dotYeah, I don't have the quotes
10:49duck1123what's the best way to exit from the repl? So far, I've just been hitting C-c, or otherwise killing the connection.
10:50jdzC-d?
10:50ChouserEOF -- ^D on unix, ^Z on windows
10:50duck1123ok
10:57j-dotChouser: in your example, how do you plan on passing the clojure code off to clojure? since "#" isn't a comment char in clojure, foo.clj can't be a straight clojure script.
10:59jdzj-dot: #! can be a nice reader macro
11:02jdzhow does one make a string out of a bunch of characters?
11:03j-dotjdz: (apply str '(\a \b \c))
11:07duck1123#! should be a reader macro for ;
11:08duck1123for those times when you want to start a comment with twice as many characters :)
11:12fogusAm I completely braindead, or only mostly-so? http://clojure.pastebin.com/d4f598985
11:18wwmorganis this what you're trying to do? http://clojure.pastebin.com/m75ecfc99
11:20Chousuke/usr/bin/clj could just be a wrapper that execs java and clojure. http://clojure.pastebin.com/m75ecfc99
11:20Chousukeeh
11:20ChousukeI didn't intend to say that.
11:20fogusThat is it. So 'class' means: dispatch on class?
11:20wwmorganfogus: class is just a function. (class obj) evaluates to the class of obj
11:21fogusI see. That makes more sense
11:22fogusThanks for the clarification
11:26Chouserj-dot: yeah, I dunno. there is the trick on the wiki.
11:26j-dotyeah, I like that trick, but I haven't used it myself
11:27j-dotWhat about clojure.lang.Script treating the first line differently if it starts with a shebang?
11:27j-doti.e., ignoring it
11:28ChouserI think that'd make a lot of sense, but I don't have any idea what rhickey would think of it.
11:28cemerickrhickey: Shouldn't Float/TYPE => #=java.lang.Float/TYPE, not #=float?
11:29cemerickI'm still unsure of my footing with #=, etc
11:31alvin-xwhat's the best way to get a java.util.Map from a clojure.lang.PersistentArrayMap?
11:32rhickeycemerick: yeah, looks like they'll need special handling
11:32rhickeypatch welcome
11:32cemerickrhickey: of course, (.getName Float/TYPE) => "float", so perhaps RT.classForName should be the target of the patch?
11:36rhickeycemerick: no, Java defines the name of those types, I don't want to mask that
11:36rhickeytrying to find a #= expression to do this, #=java.lang.Float/TYPE won't work
11:38Chousukealvin-x: just cast it?
11:39rhickeyuser=> (instance? java.util.Map {:a 1})
11:39rhickeytrue
11:40alvin-xException in thread "main" java.lang.ClassCastException: clojure.lang.PersistentArrayMap incompatible with java.util.Map
11:41rhickeyalvin-x: what version of Clojure?
11:41alvin-xrhickey: clojure_20080916, Java 5, IBM J9
11:42cemerickrhickey: array classes are also in a tight spot (#=[Ljava.lang.Object;)
11:43alvin-xuser=> (instance? java.util.Map {:a 1})
11:43alvin-xfalse
11:43alvin-x!
11:43Chouseralvin-x: too old. :-(
11:44alvin-xChouser: Clojure, or Java?
11:44Chouseralvin-x: clojure maps have implemented java.util.Map since Oct 6
11:44ChouserClojure.
11:44alvin-xok, i'll try from svn.
11:45Chouseryep, svn + ant should do it for you.
11:46cemerickI think I'm not yet clear on the semantics of #=, but it seems like #=(identity Float/TYPE) would work as a readable Float/TYPE, etc.
12:04alvin-xChouser: thanks for the tip
12:05Chouseralvin-x: got it working?
12:05alvin-xChouser: yep; hit other problems regarding RMI, but the problem with Maps is gone.
12:06Chousergreat.
12:12cemericklisppaste8: url?
12:13lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
12:14rhickeycemerick: are you using print/read for serialization now?
12:17cemerickrhickey: no, I just ran into this issue while experimenting/learning about #=, etc.
12:17lisppaste8cemerick pasted "rhickey: potential print-method patch for primitive classes?" at http://paste.lisp.org/display/69118
12:18cemerickrhickey: hope that's what you were aiming for; it seems to work, although I know I don't know the edge cases at work here.
12:19cemerickI know you've said that throwing exceptions is a no-no in the core, but I'm not sure what else to do in that case.
12:19cemerickit's too bad there's no .getBoxedClass or somesuch on java.lang.Class
12:52lisppaste8fogus pasted "fogus" at http://paste.lisp.org/display/69119
12:57rhickeycemerick: can just use a map instead of cond, no need for :else
12:59cemerickrhickey: for some reason, I had thought you wouldn't like that. That's good though, as there should be a canonical mapping to support emitting primitive class-symbols in macros.
12:59wwmorganfogus: I got a significant speed-up between the first and consequtive runs of (time (mri odd? (range 10000))). Also, remove is now part of the API
13:00wwmorgan43ms to 13ms
13:01foguswwmorgan: strange, my second call was 2x slower
13:03sohailso if someone wanted to make and distribute some clojure code, do they currently have to ship the source code or can they compile it to class files or some other object files?
13:04wwmorganfogus: also, since your function (and remove) is lazy, you should probably do (time (doall (mri ...)))
13:06foguswwmorgan: Wrapping it with doall was very different. ~40ms vs. 4ms
13:27dmiles_afkdoes clojure work ok in IKVM?
13:32drewrdmiles_afk: Check out http://is.gd/4INp
13:33dmiles_afkthanks drewr
13:47Chousersohail: currently you ship the clojure source for your app (though it can be bundled in a .jar)
13:49sohailChouser, I guess that it is written in clojure is enough to stop people from trying to tweak it :-)
14:18lisppaste8cemerick annotated #69118 with "rhickey: potential print-method patch for primitive and array classes, pt. 2" at http://paste.lisp.org/display/69118#1
14:19cemerickthat seems to handle primitive and array classes properly
14:27sohailcan someone verify this for me... clojure has a fixed set of types and you cannot extend the type system by defining compound or aggregate types (you have to use struct maps which are of class StructMap)
14:28Chousera map of vectors or a vector of maps is not a compound nor aggregate type?
14:28sohailit is, but one isn't distinguished from another except by comparing each element
14:28sohailthey aren't tagged automatically, I guess
14:29Chouseror by comparing metadata.
14:29sohailah
14:29Chouserwhich as you suggest isn't added automatically
14:29sohaildoh
14:30ChouserI've got half a blog post written on structmaps and multimethods, but I need a better concrete example than what I've got currently.
14:30sohailcan I see it?
14:30sohailwhere is your blog, btw
14:31ChouserIt's pretty sparse. Must of my clojure-related writing goes right here, or on the google group.
14:31Chouserhttp://blog.n01se.net/
14:32Chouserthere's actually a few authors there, but it's the only blog I post to.
14:32Lau_of_DKEvening gents
14:33ChouserLau_of_DK, you little devil, you've got me mired in projecteuler again.
14:33Lau_of_DKI really wish you'd find another nickname for me, but I'm glad you decided to have some fun with us :)
14:36Chouser"fiend" rather than "devil"?
14:36Lau_of_DKalmost there, add 1x 'r' and Im good :)
15:05cemerickusing a build from clojure head, I'm seeing stack traces with line numbers that are within ns forms -- is this to be expected?
15:25Lau_of_DKFilter is lazy right ?
15:25wwmorganLau_of_DK: yes
15:25Lau_of_DKk
15:26kotarakLau_of_DK: (doc filter) says so, ;)
15:27wwmorganalso (do (filter even? (repeat 2)) 1)
16:06Lau_of_DK(.. "Hi there" toUpperCase) - Why does this complain about "Hi there" not being recognized as a Symbol when "Hi there".toUpperCase() would fly in Java ( I assume, it would in C# ), and by does (.. (String. "Hi") toUpperCase not work either?
16:06drewr(.toUpperCase "Hi there")
16:08wwmorganor (. "Hi there" toUpperCase)
16:09drewrThat style will be deprecated, but you're right, that's probably what Lau_of_DK was trying to do.
16:09wwmorganoh really? Was that on the group
16:09wwmorganthe .method style makes more sense but I didn't know it was going away
16:10Lau_of_DKdrewr, your example says tht "there" is not a known symbol
16:10ChousukeI think it was in the TODO that rhickey pasted a while ago.
16:10ChousukeLau_of_DK: check your typing.
16:10Chousukemaybe you forgot a quote?
16:10drewrChousuke: Yep. Doesn't mean it's set in stone, but I think it's likely.
16:11ChousukeI suppose it's not that useful
16:11Lau_of_DKChousuke, checked it, its copy/pasted
16:13drewrLau_of_DK: Make sure your IRC client isn't changing the double-quote character.
16:13drewr(.toUpperCase "Hi there!")
16:13drewr"HI THERE!"
16:13kotarakLau_of_DK: is .. supposed to be a .?
16:14Lau_of_DKIs there a command in clojure that will show which rev. Im on ?
16:14drewrNo, I think rhickey voted that down a while back.
16:14drewrSomeone might have changed his mind later, but I'm not sure.
16:14Lau_of_DKok
16:14Lau_of_DKIts funny
16:14Lau_of_DK(.toUpperCase "Hi there!")
16:14Lau_of_DKERROR
16:15Lau_of_DK(.toUpperCase "Hi there!")
16:15Lau_of_DK"HI THERE!"
16:15Lau_of_DKI think my Chimp might be misbehaving
16:15Lau_of_DKBut thanks for the help everybody
16:27Chouser(take 3 (filter #(do (prn :test %) true) (range 10)))
16:27ChouserWhy does that test 3?
16:29wwmorganbecause take tests (seq coll) eagerly
16:30Chousertake doesn't test anything, does it?
16:30Chouser(take 3 (iterate #(do (prn :take %) (inc %)) 0)
16:32wwmorgan(seq coll) is always true if coll is an iteration
16:32Chouserfilter tests, and you're right it seems to do one extra eagerly.
16:33wwmorganyeah you could change the implementation of take
16:35wwmorganactually, I'm not sure about that
16:35drewrIf I lazy-cat together lazy-cons, will the second lazy-cons ever get called?
16:36ChouserI suspect it's the (if (pred (first coll)) ...) in take, because that's outside of any lazy-cons
16:36drewrA lazy-cons doesn't be definition have to be infinite, does it?
16:36drewrs/be /by /
16:36Chouserdrewr: right, it could eventually return nil instead of another lazy-cons, and then lazy-cat would go to the next one.
16:36kotarak(lazy-cons 5 nil)?
16:37drewrkotarak: Good point.
16:38kotarakdrewr: it just means, the contents don't get evaluated until accessed.
16:38Chouserwwmorgan: you're right, it's take's fault.
16:38Chouseroh, dangit, messed up my test. ok, still not sure. :-)
16:38Lau_of_DKIs there something similar to Contains? that would work on a vector of strings?
16:38drewrI'm trying to figure out why lazily pulling queries from a db hangs after the first one.
16:39ChouserLau_of_DK: that's a linear search, which means it'll be slow.
16:39ChouserLau_of_DK: so rhickey has resisted having a builtin, but you can still say (some #{"word"} [...])
16:39Lau_of_DKChouser, enlighten me, you want a hash map then?
16:40Lau_of_DKResistance is futile
16:40Chouseryeah, or a hash-set. both would be much faster for looking up a given word.
16:40Lau_of_DKok, and then just use contains?
16:41Chouseror just call the set
16:41Lau_of_DKhow do I automate the calling ?
16:42Chouser(def dict #{"one" "two" "three"})
16:42Chouser(dict "one") -> true
16:42Chouser(dict "five") -> nil
16:43Lau_of_DKAlright, while we're at it, I know that Strings have a split function, how do I split every word into a single item, like in C# you could do "Hi there Chouser".Split(" ") = ["Hi" "there" "Chouser"]
16:44Chouser(apply hash-set (.split "Hi there Lau"))
16:45Chousersorry: (apply hash-set (.split "Hi there Lau" " "))
16:47Lau_of_DKThanks
16:47Chouserwwmorgan: ok, you're definitely correct. It's take.
16:48Chouser(first (filter #(do (prn :test %) true) (range 10))) only tests one
16:48Chouserbut if you use (take 1 ...) it tests 0 and 1
16:48wwmorganright. it checks for logical truth before it decides whether to return a lazy-cons or nil
16:49Chouser"take" does? (seq coll) doesn't realize either the "first" or the "rest" parts of a lazy-cons, does it?
16:50Chouseroh, it does!
16:50wwmorganit does on a filter, because it has to make sure that at least one remaining element passes the test
16:51Chouserman, this is subtle.
16:52wwmorganthat's why you didn't see the same behavior on your iterate: an iteration is always logically true
16:52Lau_of_DKlogically :)
16:53Lau_of_DKuser=> (containsEnglishWords? "hej med dig, min amerikanske ven er usually meget good")
16:53Lau_of_DK("usually" "good")
16:53Lau_of_DKsweet, good thinking Chouser :)
17:15lisppaste8Chouser pasted "take (fixed)" at http://paste.lisp.org/display/69146
17:16ChouserWith that, this only tests 0, 1, and 2:
17:16Chouser(take 3 (filter #(do (prn :test %) true) (range 10)))
17:19cemerickrhickey: did you see this earlier, or no? I've been in and out myself: http://paste.lisp.org/display/69118#1
17:20rhickeycemerick: I didn't - looks good, thanks! - could you please post to the group?
17:20cemerickrhickey: yeah, I will, thanks
17:21cemerickI wasn't really around for any of the conversation about making a print multimethod, etc., but so far, I'm not enamored of the approach so far
17:22cemerick(I hate to be one of those people that pops up with opinions long after decisions are made and code is written :-) )
17:23rhickeycemerick: what would you propose instead?
17:23cemerickIt seems like there's a lot of niggly details that will need to be resolved (e.g. classnames of primities and arrays), a lot of reinventing the wheel given that there's a *lot* of serialization mechanisms for Java.
17:24Chousercemerick: are you talking about multimethod vs. written in Java? Or the new #= format?
17:26cemerickI suppose the #= format. There's nothing to say that the existing javabean serialization (for example) couldn't just get dropped into a form that the reader would bring back in transparently. There's less lispy love there, but I worry about what dragons await yet another serialization mechanism.
17:27cemerickI'm sure I've not thought about the issues nearly as much as others, so take all this with the requisite pound of salt. :-)
17:27ChouserI don't think there was any discussion of the #= format. :-)
17:28rhickeycemerick: I looked at JavaBean serialization - it's unconscionably verbose
17:29cemerickdefinitely so, but it works, and has a lot of support behind it so it will "automatically" grow along with new JDK versions, etc
17:30cemerickis verbosity an issue, though? How often would we expect serialized objs to be viewed by humans?
17:30rhickeyum, every time they work at the repl?
17:31cemerickthere's clearly some benefits to having everything be printed readably all the time, but the repl vs. storage vs. transmission are very different use-cases
17:32Chouserthe old print format didn't work for storage or transmission of unusual Java objects either, did it?
17:33rhickeycemerick: print/read is a strong and valuable Lisp tradition, nothing about it removes other serialization mechanisms
17:33cemerickChouser: no, not at all
17:35cemerickrhickey: Sure. I guess I'd just worry about having to keep print-method well-fed.
17:36cemerick...in addition to whatever odd corner-cases exist w.r.t. Java idiosyncrasies
17:36cemerickThis is all monday-morning quarterbacking on my part though, so I think I'll just sit back down. :-)
17:38rhickeyI think Javabeans serialization might be a good fallback if no other method is defined, the current default has only been marginally useful
17:39cemerickrhickey: hrm, having a featureful fallback is a good idea. I suspect Javabean serialization is just a baseline though -- I'm sure there's better options. I brought it up only because I'm familiar with it.
17:43duck1123so is anyone here familiar with compojure?
17:43duck1123I'm still having troubles getting the compojure repl connected via slime
17:44cemerickhuh, looks like the google group email gateway has gotten snappier
17:44lisppaste8rhickey pasted "XMLEncoder format" at http://paste.lisp.org/display/69149
17:45rhickeycemerick: it is text, but another problem is its graph nature
17:45cemerickoh, yeah, it can get vile -- but for storage/transmission, it's great as long as it's zipped
17:46cemerickI've not thought much about serialization issues -- I'm not aware of the problem(s) with object graphs.
17:49cemerickhave a good weekend, everyone!
17:51drewrIn JSwat, I see a Timestamp object, but its value is "#2455."
17:51drewrIs that a memory address?
17:51drewrCan I only inspect strings?
18:00islonhi guys o/
20:31sohailis let like let* or like let from CL
20:32rhickeysohail: like let*
20:32sohailthanks rhickey, I am not very good at navigating the documentation
21:20RadioApeShotQuestion, is there a predicate which detects whether a thing is seq-able?
21:20drewr(doc seq?)
21:20RadioApeShotseq? detects if a thing _is_ a seq
21:21drewrTrue.
21:21RadioApeShotSo (seq? [1 2 3]) -> false
21:21RadioApeShotSuppose one wanted to write a function which returns the first of a thing if the thing is seq-able, like a vector
21:22drewrIdiomatically, you just (when (seq [1 2 3]) ...)
21:22RadioApeShotBut otherwise returns something else
21:22RadioApeShotwhen
21:22RadioApeShotVery clever.
21:22RadioApeShotThanks
21:23RadioApeShotBut wait
21:24RadioApeShot(defn first-or [x y] (when (seq x) (first x) y))
21:24RadioApeShotThat still will not work
21:24RadioApeShotAt least it will not if x is, for instance, a symbol
21:25RadioApeShotbecause (seq x) will throw an exception
21:25drewrYes, you need to be fairly certain you're getting some kind of collection.
21:25RadioApeShotIs there a collection?
21:25RadioApeShot(collection? x)
21:26RadioApeShotI am just porting some Scheme code where I use the nth-or idiom a lot.
21:26drewrCan you wrap it in a try and deal with the exception?
21:26RadioApeShotBut I am trying to make this collection independent.
21:26RadioApeShotI can do that
21:26RadioApeShotIt just seems a bit weird to do so.
21:27drewcis there an IGNORE-ERRORS in clojure?
21:27RadioApeShotNot that I know of.
21:28drewcseems like a use-case.. though quite frankly i avoid it in CL and prefer the explicit error handlers.
21:28drewc (defn first-or [x y] (when (ignore-errors (seq x)) ...)
21:28RadioApeShotOk
21:28RadioApeShotPlace is closing
21:28RadioApeShotGotta run
21:28RadioApeShotThanks for the help
21:29RadioApeShotI appreciate it
21:30drewr(doc coll?)
21:36drewrdrewc: How are you liking clojure so far?
21:37drewcdrewr: having a lot of fun so far :)
21:38drewrAwesome.
21:38drewcdrewr: i have not been working with it long enough for any of my grievances to have any real merit.
21:38drewclisp-1 is driving me nuts, but i'm willing to look past it :)
21:39drewrHaha.
21:40drewrWe incited some discussion about that at dinner before lisp50.
21:41drewcme, i'm just exited that there is a new lisp actually worth looking at. Rich has put an incredible amount of thought into it, and he has the cojones to go through with it.., i'm suitably impressed.
21:42drewctalking
21:42drewr:-)
21:46drewcI'm getting used to the syntax even .. who'd a thunk it.
21:49drewrI find it extremely expressive.
22:00drewcwhat i absolutely _love_ is STM
22:09rhickeyNice blog from OOPSLA: http://lispy.wordpress.com/2008/10/25/lisp50-notes-part-vi-the-future-of-lisp/
22:16danlarkinthe default wordpress template annoys me so much
22:17danlarkinbecause when I increase the font to a readable size then only like 5 words fit on a line