2011-12-03
| 00:08 | seancorfield | quick Q: playing with george jahad's cdt and his instructions say run lein swank and connect to it as you usually do... i have been doing clojure-jack-in from emacs... |
| 00:08 | seancorfield | what's the "usual" way to connect emacs to a swank server? |
| 00:09 | georgek | slime-connect |
| 00:10 | seancorfield | so obvious ... thank you! |
| 00:10 | georgek | it's funny I can't get jack-in to work at the moment :) |
| 00:10 | georgek | technomancy, I updated clojiure-mode and swank-clojure, I get the error error in process filter: Opening input file: no such file or directory, c:/Documents and Settingsgeorge/.emacs.d/swank/slime-cdf283b4.e |
| 00:11 | georgek | oops just noticed that file path, weird |
| 00:11 | seancorfield | wow, cdt is freakin' cool!!!! |
| 00:30 | seancorfield | how many different slime connection buffers can you have open in emacs? |
| 00:32 | mtkoan | is it possible to get syntax highlighting in the slime repl in emacs? |
| 00:32 | seancorfield | and is clojure-jack-in just shorthand for run lein swank and then M-x slime-connect ? (but focused on the project in hand) |
| 00:34 | mtkoan | i tried adding the line (add-hook 'slime-repl-mode-hook 'clojure-mode-font-lock-setup) |
| 00:35 | mtkoan | it seems to have no effect with M-x clojure-jack-in, and with slime-connect i get: Symbol's function definition is void: clojure-mode-font-lock-setu |
| 00:35 | mtkoan | p |
| 00:36 | georgek | mtkoan: yes |
| 00:36 | georgek | are you connecting locally or remotely? |
| 00:36 | mtkoan | locally |
| 00:37 | georgek | you need to require clojiure-mode before adding the hook |
| 00:37 | georgek | if you're not jacking in but using slime-connect |
| 00:38 | georgek | seancorfield, if you're using different ports I imagine as many as you want |
| 00:39 | mtkoan | ok |
| 00:40 | mtkoan | no error with slime-connect, but still not syntax highlighting either |
| 00:40 | georgek | strange, just looked in my .emacs and that's what I have |
| 00:41 | mtkoan | hm |
| 00:43 | mtkoan | individual words get highlighted? |
| 00:43 | georgek | I think I know what you mean, yes |
| 00:45 | mtkoan | highlighting works editing clj files, but not the repl.. oh well |
| 00:46 | georgek | can I see your .emacs? |
| 00:46 | seancorfield | georgek: thanx. suspected as much but wanted to confirm "bad things" wouldn't happen :) |
| 00:46 | seancorfield | i'm off for the night... |
| 00:46 | georgek | just tried it here and it works fine |
| 00:46 | georgek | seancorfield, well I'm no expert on that :) |
| 00:50 | mtkoan | i have no .emacs, its all in .emacs.d/init.el .. is that wrong? |
| 00:50 | mtkoan | I am new user to emacs as well ;) |
| 00:50 | georgek | no, that's it, sorry I was just using a different term |
| 00:51 | tensorpudding | .emacs.d/init.el is the same |
| 00:51 | tensorpudding | i use it too |
| 00:52 | georgek | I updated to latest swank-clojure and clojure-mode, and now on jack-in slime is looking for filepaths like "C:\Documents and Settings\george/.emacs.d/swank/slime-cdf283b4.elc, which doesn't even exist |
| 00:52 | mtkoan | georgek: http://pastebin.com/71YwSWV7 |
| 00:53 | georgek | there's a typo in clojure-mode |
| 00:54 | mtkoan | ahh i rest removed and added it back in |
| 00:54 | mtkoan | *just |
| 00:54 | mtkoan | but it wasn't working with it spelled right too I promise ;) |
| 00:54 | georgek | ok, I believe you :) |
| 00:54 | hiredman | is it a typo? or is in technomancy letting windows users fend for themselves? |
| 00:55 | georgek | don't know hiredman, there's a somewhat related thread on the mailing list but I don't quite get it |
| 00:55 | georgek | jack-in used to work fine |
| 00:55 | georgek | lein swank from the command line works fine |
| 00:55 | tensorpudding | jack-in has stopped working for me too |
| 00:56 | tensorpudding | but with a different error |
| 00:56 | georgek | what error? |
| 00:56 | tensorpudding | can't remember the wording right now |
| 00:56 | georgek | I only updated because earlier it wasn't working for a different reason |
| 00:56 | hiredman | most likely thread the thread on the mailing list is someone saying "this doesn't work on windows" and technomancy saying "oh, well, windows, I don't have that so fix it and let me know how you did it?" |
| 00:56 | georgek | something like that :), but that user is on cygwin |
| 00:56 | georgek | but in any case, it used to work on Windows great |
| 00:57 | tensorpudding | error in process filter: Symbol's function definition is void: slime-face-inheritance-possible-p |
| 00:57 | tensorpudding | that was the error |
| 00:57 | hiredman | technomancy is not one to go out of his way for people that don't run on linux, don't use eshell or bash |
| 00:58 | georgek | that's fine, the alternative is to have no tool after all |
| 00:58 | hiredman | tensorpudding: what version of swank clojure? |
| 00:59 | tensorpudding | i'd have to check |
| 00:59 | tensorpudding | it's the latest on marmalade |
| 00:59 | hiredman | um |
| 00:59 | tensorpudding | when i checked a few days ago |
| 00:59 | hiredman | swank-clojure is not in marmalade |
| 00:59 | hiredman | clojure-mode is |
| 01:00 | hiredman | swank-clojure is a jar |
| 01:00 | tensorpudding | oh wait, right |
| 01:00 | tensorpudding | was thinking clojure-mode |
| 01:00 | hiredman | you may want to try a SNAPSHOT of swank-clojure |
| 01:00 | hiredman | https://github.com/technomancy/swank-clojure/commit/815a14db85c6512659752dde8f57d1f6145b3ddc |
| 01:01 | tensorpudding | this was the snapshot version |
| 01:01 | tensorpudding | i haven't fetched a new one recently |
| 01:08 | mtkoan | eureka |
| 01:09 | mtkoan | if i mouse2 on REPL, de-select font lock, and re-select I get syntax highlighting xD |
| 01:11 | tensorpudding | i can live with jack-in not working |
| 01:33 | georgek | I think I found a patch that would fix the weird filepath issues I'm having with jack-in, but it's not pulled into the official swank-clojure...sorry I'm new at this, but I would have to rebuild the swank-clojure jar if I make that change myself, right? I can't just make the change in the .clj file in the swank-clojure jar and be good to go |
| 02:45 | georgek | OK, found a different fix that worked here https://github.com/technomancy/swank-clojure/issues/72. |
| 03:00 | bloop | I have a question about vars, but it pertains to this page: http://clojure.org/atoms why is it that the second call to fibs was already memoized? is it because that's how vars work or because the example is not precise? |
| 03:34 | tscheibl | good morning clojurians |
| 06:06 | AnswerGuy | Is there a Clojure REPL with enhancements analagous to those of iPython over the stock Python >>> interpreter/mode? |
| 06:07 | AnswerGuy | Or is Clojure + rlwrap or + Jline/Jline2 (analagous to Python >>> import readline, rlcompleter) the best option? |
| 06:22 | ejackson | AnswerGuy: as far as base repl, yeah. What you want though is to have the repl within a larger environment CCW/Emacs |
| 06:24 | AnswerGuy | CCW? There's an Emacs (or XEmacs?) module/wrapper around (interface to) the Clojure REPL? |
| 06:24 | ejackson | AnswerGuy: CCW = Counterclockwise, an Eclipse mode |
| 06:25 | ejackson | AnswerGuy: check out http://dev.clojure.org/display/doc/Clojure+Tools |
| 06:29 | zakwilson | Most people using Emacs use Slime and swank-clojure. |
| 08:32 | licenser | pauldoo: with point-free you mean not calling object functions? |
| 08:33 | pauldoo | I mean no variable names (or function argument names) |
| 08:33 | pauldoo | functions are made by composition |
| 08:42 | licenser | is that a good thing? |
| 08:42 | licenser | I mean I understand the elegance behind it but is it good for maintainabiltiy/readability? |
| 08:43 | pauldoo | so far, it appears to be a terrible idea…. though perhaps a fun exercise in higher order functions |
| 08:43 | pauldoo | maybe the results can be reused more flexibly, since the shape of the function/args is even looser than normal |
| 08:44 | pauldoo | licenser: http://en.wikipedia.org/wiki/Tacit_programming "Outside of the APL and J communities, tacit programming is referred to as point-free stylehttp://en.wikipedia.org/wiki/Tacit_programming#cite_note-0, or more pithily as pointless programming" |
| 08:44 | licenser | pauldoo: I love that there are people like you |
| 08:45 | pauldoo | thanks :) |
| 08:45 | licenser | programming would be so boring if everyone would just stick to what is good and not just try things even so they seem, and I quote you here 'a terrible idea' |
| 08:45 | tscheibl | uhm.. how do I check for a Java array? (sequential? ...) does not work |
| 08:49 | tscheibl | anyone? please... |
| 08:49 | tscheibl | I'm stuck |
| 08:51 | pauldoo | just thinking... |
| 08:53 | pauldoo | you can check for the class.. (class (int-array 3)) |
| 08:54 | pauldoo | gives [I for an int array.. |
| 08:54 | pauldoo | [Ljava.lang.Object; for an object array.. |
| 08:55 | tscheibl | yeah.. but I need this generically... don't wan't to check for every possible array type |
| 08:55 | Bronsa | ,(-> (object-array 1) .getClass .isArray) |
| 08:55 | tscheibl | want |
| 08:55 | clojurebot | true |
| 08:55 | tscheibl | ahh |
| 08:56 | tscheibl | ,(.isArray (class (int-array [3 4 5]))) |
| 08:56 | clojurebot | true |
| 08:56 | tscheibl | thanks |
| 08:56 | tscheibl | very much... |
| 08:56 | Bronsa | np |
| 08:57 | tscheibl | I was stuck for almost 30 minutes... |
| 08:57 | tscheibl | before I asked... |
| 08:57 | Bronsa | tscheibl: do you need to check if it is an array or if it is seqable? |
| 08:57 | tscheibl | nah .. i it is a Java Array explicitly |
| 08:57 | Bronsa | because in core.incubator you have "seqable?" |
| 08:57 | Bronsa | ok |
| 08:58 | tscheibl | because jdbc returns java arrays from sql arrays and I need to convert them |
| 08:58 | tscheibl | I mean... seqable probably would also work and be more clojurish :) |
| 08:59 | tscheibl | just need to check if a String is also seqable? |
| 09:00 | Bronsa | https://github.com/clojure/core.incubator/blob/master/src/main/clojure/clojure/core/incubator.clj#L85 |
| 09:00 | Bronsa | it does |
| 09:00 | Bronsa | *is |
| 09:02 | tscheibl | i see.. so I'll go for .isArray, thx again :) |
| 09:35 | pauldoo | what's the syntax for using goog.Timer in clojurescript? I've got (ns hello (:use [goog :only [Timer]])) |
| 09:35 | pauldoo | this works in normal compile, but not optimized compile |
| 10:20 | TimMc | $mail tmciver [& more] says "Give me the rest of the args as a collection." [& [more]] says "The rest of the args is a collection, and just bind the first element as 'more'." |
| 10:20 | lazybot | Message saved. |
| 10:24 | TimMc | &((fn [& {a :a}] a) :a 2 :b 4) ; oh, huh |
| 10:24 | lazybot | ⇒ 2 |
| 10:25 | TimMc | Apparently you can destructure a vector as a map. |
| 10:25 | TimMc | &((fn [& {a :a}] a) :a 2 :odd...) ; this would be a cryptic error message |
| 10:25 | lazybot | java.lang.IllegalArgumentException: No value supplied for key: :odd... |
| 10:27 | TimMc | $findfn + {1 2 3 4} 10 |
| 10:27 | lazybot | [] |
| 10:47 | _ulises | can anybody point me to some reading material that explains what is a symbol? |
| 10:49 | chewbranca | _ulises: search for symbols on this page: http://java.ociweb.com/mark/clojure/article.html there is also a ton of other good stuff on that page, definitely worth reading |
| 10:49 | _ulises | awesome, thanks! |
| 10:50 | _ulises | I always get confused by symbols. Sometimes I think they are just "labels" to name things, sometimes I think there's probably a lot more to them. At some point they were just keys in a map, almost like pointers, but surely that is wrong too. |
| 10:51 | _ulises | So I'd definitely welcome some enlightenment in this area. |
| 10:54 | TimMc | _ulises: In other Lisps they often serve a dual purpose. |
| 10:55 | _ulises | hum, ok? |
| 10:56 | TimMc | and in Clojure, keywords have taken over part of that. |
| 10:56 | Chousuke | and vars |
| 10:56 | TimMc | mmm |
| 10:56 | Chousuke | in CL for example the thing that holds a value is the actual symbol (as far as I know, anyway) |
| 10:56 | Chousuke | in Clojure, the symbol is just a name for the var that holds the value |
| 10:56 | _ulises | so in clojure a symbol points to a var which holds/points to a value? |
| 10:57 | TimMc | or is just a local binding. |
| 10:57 | Chousuke | the symbol names a var, it doesn't point to it |
| 10:57 | _ulises | right |
| 10:57 | _ulises | so it is a label |
| 10:57 | TimMc | Symbols name things which can get you values. |
| 10:57 | _ulises | not much more mystery to it? |
| 10:57 | Chousuke | there is no pointer or reference from a symbol to anything |
| 10:57 | Chousuke | yeah |
| 10:57 | _ulises | why was I then so confused? perhaps I read somewhere else about other lisps |
| 10:57 | Chousuke | might be |
| 10:58 | _ulises | ok, cool |
| 10:58 | TimMc | Keywords are *just* names, which multiple things might know about. They're used in informal APIs or data formats. |
| 10:58 | _ulises | so, once you have a symbol, you get the thing it labels by evaling it? |
| 10:58 | Chousuke | pretty much yeah |
| 10:59 | Chousuke | that only works for global things though; eval doesn't have access to local scope |
| 10:59 | _ulises | oh? |
| 10:59 | TimMc | _ulises: Clojure doesn't have "reified environments" -- you can't inspect a let's bindings. |
| 11:00 | TimMc | Well... maybe. There's some macro hack... |
| 11:00 | Chousuke | macros have the &env parameter but it's not quite the same |
| 11:00 | TimMc | Yeah, what *does* that give you? |
| 11:00 | Chousuke | just the expansion environment I think |
| 11:01 | _ulises | ok, now I'm definitely out of my depth :) |
| 11:01 | Chousuke | heh :P |
| 11:02 | _ulises | ok, so, symbols are labels and nothing else, keywords are like labels but have extra functionality such as value lookup in maps |
| 11:02 | _ulises | right or wrong? |
| 11:02 | TimMc | Keywords don't name values. |
| 11:03 | pauldoo | keywords evaluate to themselves, symbols evaluate to a value depending on the environment |
| 11:03 | _ulises | ah! true. |
| 11:03 | _ulises | hello Mr.Paul. |
| 11:03 | pauldoo | 'lo o/ |
| 11:04 | _ulises | \o. |
| 11:04 | Chousuke | keywords are useful as map keys because they evaluate to themselves |
| 11:04 | _ulises | Chousuke: oh? explain please? |
| 11:04 | Chousuke | ,('foo {'foo :bal}) but this works too IIRC :P |
| 11:04 | clojurebot | :bal |
| 11:04 | _ulises | but 'foo is a symbol? |
| 11:04 | Chousuke | yes |
| 11:05 | Chousuke | symbols are just fine as map keys |
| 11:05 | _ulises | and they look themselves up? |
| 11:05 | Chousuke | Yes. keywords are just used because they're a bit more efficient since they're singletons |
| 11:05 | _ulises | well, clearly, from the example above |
| 11:05 | Chousuke | and I guess the syntax is a bit nicer |
| 11:05 | _ulises | ah, hence the tendency to use them as map keys |
| 11:05 | Chousuke | ,(identical? :foo :foo) |
| 11:05 | clojurebot | true |
| 11:06 | Chousuke | ,(identical? 'foo 'foo) ; I guess this might return true too |
| 11:06 | clojurebot | false |
| 11:06 | _ulises | yes, awesome |
| 11:06 | pauldoo | I think it's a bit subtle using unevaluated symbols as keys (imho) |
| 11:07 | _ulises | I had no idea symbols could look themselves up in maps |
| 11:07 | _ulises | ,('foo #{'foo 'bar}) |
| 11:07 | clojurebot | foo |
| 11:07 | _ulises | yas |
| 11:07 | Chousuke | works for anything associative really |
| 11:07 | pauldoo | unentended symbols should really only be used for sexpressions, bits of code in otherwords |
| 11:07 | pauldoo | s/unentended/unevaluated/ |
| 11:08 | pauldoo | otherwise, you might as well say we can use random expressions as keys.. |
| 11:08 | Chousuke | well you can |
| 11:08 | _ulises | heh |
| 11:08 | Chousuke | there's nothing wrong with using eg. a vector as a map key |
| 11:08 | pauldoo | ,('(* 2 3) {'(* 2 3) 5}) |
| 11:08 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn> |
| 11:08 | pauldoo | ,({'(* 2 3) 5} '(* 2 3)) |
| 11:08 | clojurebot | 5 |
| 11:09 | Chousuke | that's perfectly valid |
| 11:09 | pauldoo | but I see what you mean there, about symbols acting as the fn |
| 11:09 | Chousuke | if you want to associate some data with a piece of code for example. |
| 11:09 | pauldoo | yep - it's valid I agree |
| 11:09 | Chousuke | also you can add metadata to symbols |
| 11:09 | pauldoo | but perhaps a little subtle/misleading to use a small bit of code (an unevaluated symbol) like this.. |
| 11:09 | Chousuke | so if you need metadata on map keys for some reason you can use symbols |
| 11:10 | _ulises | interesting |
| 11:10 | TimMc | (defmacro foo [] (vec (map str (keys &env)))) |
| 11:10 | TimMc | (let [x 5] (let [y 9] (foo))) -> ["y" "x"] |
| 11:11 | Chousuke | it gives you the local env and the forms that they're bound to. |
| 11:11 | Chousuke | not values, mind you. that's not known until runtime :P |
| 11:11 | pauldoo | plus I think you'll get into trouble with namesaces if you use symbols as map keys.. |
| 11:12 | TimMc | The vals of &env are clojure.lang.Compiler$LocalBinding |
| 11:12 | TimMc | You can't pass them to the callsite. |
| 11:12 | Chousuke | I think the core.logic library uses &env to figure out free and bound variables. |
| 11:12 | Chousuke | so you don't need ?blah |
| 11:12 | Chousuke | it's pretty clever |
| 11:13 | TimMc | And entirely unhygienic. :-P |
| 11:13 | Chousuke | pauldoo: why? |
| 11:13 | Chousuke | TimMc: dunno, I don't see how it could cause problems |
| 11:14 | TimMc | I'm not saying it does. Hygiene is not mandatory. |
| 11:14 | TimMc | (morally) |
| 11:18 | mbac | what's the idiom in clojure for iterating a sequence without returning a value? i want to work through side-effects |
| 11:18 | tsally | what's the prefered way to get readline support in the repl launched by clj ? |
| 11:21 | TimMc | mbac: dorun, I think. |
| 11:21 | TimMc | mbac: I believe doall holds onto th head and returns it, whereas dorun returns nil. |
| 11:22 | TimMc | tsally: If you're using lein, install rlwrap |
| 11:22 | pauldoo | Chousuke: I'd have thought the foo/a and bar/a would be different symbols, and won't be able to lookup the same entry in a map for instance |
| 11:23 | pauldoo | Chousuke: but keywords are the same, no matter which namespace you use them in/from |
| 11:24 | TimMc | pauldoo: 'foo/a and 'bar/a and 'a are all different symbols entirely. |
| 11:25 | pauldoo | TimMc: indeed, so if code inside foo adds an entry to a map keyed by 'a, will code inside bar be able to use ('a some-map) in order to find the entry? |
| 11:26 | TimMc | If they use 'a, yes. If they use `a, no. |
| 11:26 | pauldoo | TimMc: ahhh ok, slightly different quote |
| 11:26 | TimMc | because `a will *expand* to 'namespace/a. |
| 11:26 | pauldoo | Chousuke: in that case, I was incorrect about symbols and namespace confusion. :) |
| 11:44 | _ulises | ok, back to symbols ... |
| 11:45 | _ulises | I just wrote some code which is ... well, let's not qualify it, but it definitely smells |
| 11:45 | _ulises | http://pastebin.com/56zhyR98 |
| 11:45 | _ulises | so, having access to symbols, etc. this way can lead you to writing can-of-worms code, and surely the responsibility is on me as a programmer |
| 11:45 | clojurebot | Ack. Ack. |
| 11:46 | _ulises | however it doesn't stop smelling |
| 11:46 | TimMc | clojurebot: You're terrible. |
| 11:46 | clojurebot | Cool story bro. |
| 11:46 | _ulises | o_O |
| 11:47 | TimMc | ~so, having access to symbols, etc. this way can lead you to writing can-of-worms code, and surely the responsibility |
| 11:47 | clojurebot | so, having access to symbols, etc. this way can lead you to writing can-of-worms code, and surely the responsibility is on me as a programmer |
| 11:47 | TimMc | clojurebot: forget so, having access to symbols, etc. this way can lead you to writing can-of-worms code, and surely the responsibility |is| on me as a programmer |
| 11:47 | clojurebot | I forgot that so, having access to symbols, etc. this way can lead you to writing can-of-worms code, and surely the responsibility is on me as a programmer |
| 11:47 | TimMc | good |
| 11:47 | _ulises | good bot |
| 11:48 | TimMc | marginally o\__/o |
| 11:57 | TimMc | Ugh, how can `git stash save && git stash pop` possibly cause a merge conflict? |
| 11:58 | TimMc | save --keep-index, technically |
| 12:11 | pauldoo | when I try to use goog.Timer in clojurescript, it works fine in normal compile mode. but the advanced compile errors with: ERROR - required "goog" namespace never provided |
| 12:27 | mbac | TimMc: what i meant is, i want something like foreach |
| 12:28 | mbac | (foo (fn [c] (printf "%c\n")) "abc") |
| 12:29 | mbac | i want a\nb\n\c\ sent to stdout, and the entire expression to evaluate to nil |
| 12:31 | mbac | oh, i guess i can do (doseq [c (seq "abc")] (printf "%c\n" c)) |
| 12:31 | mbac | is there something more idiomatic? |
| 12:32 | Chousuke | you don't need the seq call |
| 12:32 | _ulises | mbac: maybe (dorun (map println "abc")) |
| 12:32 | mbac | if all collections implement the seq protocol what do you use seq for? |
| 12:32 | Chousuke | mbac: they don't. |
| 12:33 | Chousuke | mbac: but doseq internally calls seq |
| 12:33 | _ulises | unless you want you want formatting with printf, then you need (partial printf "...") |
| 12:33 | Chousuke | so you don't have to |
| 12:33 | mbac | oh, that's kind of magicky |
| 12:33 | Chousuke | nah, it's just idiomatic |
| 12:34 | Chousuke | if you write a function that expects a seq, it's your job to call seq on it |
| 12:35 | mbac | wait, i'm confused. are strings collections AND sequences? |
| 12:36 | Chousuke | strings are java Strings |
| 12:36 | mbac | (first "foo") is equivalent to (first (seq "foo")) |
| 12:36 | Chousuke | but seq works on them |
| 12:36 | Chousuke | currently it's special cased in seq |
| 12:37 | tsally | is (key map) just a reader macro over (get map key) ? |
| 12:37 | Chousuke | no |
| 12:37 | Chousuke | keywords implement the function interface |
| 12:37 | tsally | what bout (map key) ? |
| 12:37 | Chousuke | so you can treat them as functions. what they do is look themselves up in an associative thing |
| 12:37 | Chousuke | maps are functions |
| 12:38 | Chousuke | ,(map {:a 1 :b 2} [:a :b :c]) |
| 12:38 | clojurebot | (1 2 nil) |
| 12:38 | Chousuke | sets are functions too |
| 12:39 | tsally | interesting.... is there a way to make the maps return a different value when key is not found? |
| 12:39 | tsally | I see how to do that with get |
| 12:39 | Chousuke | (a-map foo :val-not-found) |
| 12:40 | tsally | awesome |
| 12:40 | nickmbailey | ,({:a 1} :b 2) |
| 12:40 | clojurebot | 2 |
| 12:41 | Chousuke | maps (and sets, and vectors) being functions is one thing I really like about Clojure |
| 12:41 | tsally | and when you say keywords implement the function interface? |
| 12:41 | Chousuke | just like maps |
| 12:41 | Chousuke | they're functions too |
| 12:41 | tsally | and they expect an associative thing as an arg |
| 12:41 | Chousuke | yeah |
| 12:42 | tsally | really interesting |
| 12:42 | Chousuke | this is one thing where Clojure is ahead of all other lisps |
| 12:42 | tsally | one of a few things ^^ |
| 12:45 | tsally | can you use (key map) (map key) interchangably or is there a reason to prefer one over the other |
| 12:46 | bloop | (hours ago there was a discussion on writing Clojure ponit-free) if you think it's a fun exercise, try Unlambda |
| 12:47 | Chousuke | tsally: sometimes map might be nil |
| 12:47 | Chousuke | in which case using key first is more robust |
| 12:47 | Chousuke | or it might not be a clojure map, I guess |
| 12:48 | Chousuke | depends on the scenario |
| 12:48 | Chousuke | in general I think (:key map) is more common |
| 12:49 | pauldoo | bloop: that was me, I've stopped that little exercise now. it was preventing me from getting work done |
| 12:53 | bloop | pauldoo: well, there's always something to be said for experimentation and mind-exercises, I think. . |
| 12:54 | pauldoo | bloop: indeed - but it was distracting me from learning the real thing I wanted to learn |
| 13:06 | tsally | I'm writing a toy function that counts the length of a seq. a little baffled by this error message... https://pastee.org/ycrc8 |
| 13:07 | foodoo | tsally: Your code gets evaluated to something like this (1 2 3) and clojure tries to cast 1 to a function which doesn't work |
| 13:07 | jkkramer | tsally: "X cannot be cast to clojure.lang.IFn" generally means you're trying to call something that's not a function |
| 13:08 | jkkramer | tsally: check your parentheses nesting |
| 13:09 | tsally | foodoo: is that happening in the loop binding ? |
| 13:09 | foodoo | tsally: dunno. I'm too lazy to find out ;) |
| 13:09 | tsally | hehe fair enough ^^ |
| 13:10 | tsally | i understand what the error message means, I just dont see where i have a number in the first position of a sexp |
| 13:10 | jkkramer | tsally: your function looks correct, you just have too many parens |
| 13:10 | tsally | oh duh |
| 13:10 | jkkramer | it returns the right result (a number) and then tries to call that result |
| 13:10 | tsally | it's attempting to call the result as a funciton |
| 13:10 | tsally | jkkramer: nice catch thanks ^^ |
| 13:11 | jkkramer | tsally: two parens in a row is a usually a bug |
| 13:13 | jkkramer | tsally: also, minor thing: (nil? (seq s)) -> (empty? s) |
| 13:13 | tsally | jkkramer: ah, nice |
| 14:29 | TimMc | jkkramer: Two open parens. |
| 16:49 | seancorfield | what's the current "correct" way to build clojure from source? there appears to be both an ant build.xml and a maven pom.xml in the repo |
| 16:50 | seancorfield | ant clean jar ;; creates the clojure..jar as expected |
| 16:50 | seancorfield | mvn install ;; runs tests and builds / installs clojure..jar in the m2 repo |
| 16:50 | hiredman | either |
| 16:52 | seancorfield | i'm updating mark volkman's clojure article... (he put it on github for me to fork and update)... once i've done a basic pass and he's incorporated that pull request, i'll publicize it for more folks in the community to pile in and help update it |
| 16:53 | hiredman | I tend to run 'mvn package' if I am checking out a patch |
| 16:53 | seancorfield | 'k... i'm not familiar enough with maven to know what that does... i know clean, compile, test, install :) |
| 16:54 | hiredman | me neither, I just picked the package command up somewhere and it works with the clojure build |
| 17:03 | mbac | how can i printf to stderr instead of stdout? |
| 17:09 | duck1123 | (binding [*out* *err*] ... |
| 17:11 | duck1123 | but you might want to look into a logging library for more control |
| 18:12 | triyo | Is there a bug in `update-in` function in clojure 1.3? I try: (update-in (assoc {:id 2} :name "John" :age 31) [:id :age] inc) and get a NPE. |
| 18:13 | seancorfield | ,(assoc {:id 2} :name "John" :age 31) |
| 18:13 | clojurebot | {:age 31, :name "John", :id 2} |
| 18:13 | seancorfield | not a nested map |
| 18:14 | seancorfield | so you're trying to do (update-in 2 [:age] inc) |
| 18:14 | seancorfield | ,(update-in 2 [:age] inc) |
| 18:14 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 18:15 | triyo | oh I see, I forgot that its for nested structures. |
| 18:15 | seancorfield | did you mean: |
| 18:15 | seancorfield | ,(update-in (assoc {:id 2} :name "John" :age 31) [:age] inc) |
| 18:15 | clojurebot | {:age 32, :name "John", :id 2} |
| 18:15 | triyo | yip |
| 18:15 | triyo | apply fn to all values of keys are `select` |
| 18:15 | triyo | *are=I |
| 18:16 | triyo | so I could select all unrounded decimal values in a map; select the keys that have decimal values and apply my round-places fucntion.. |
| 18:16 | TeXnomancy | Raynes: reading about tentacles, have you considered the idea of a generalized rest-pagination lazy-seq? |
| 18:17 | Raynes | TeXnomancy: No, but that's a fantastic idea. |
| 18:17 | TeXnomancy | the only hitch is that you would need a lazy seq that could perform no-ops when it was being forced from a drop call |
| 18:18 | Raynes | Bleh. |
| 18:18 | TeXnomancy | certainly not insurmountable, but worth pondering |
| 18:19 | Raynes | TeXnomancy: I'll make an issue for that. Great idea, so thanks. |
| 18:20 | triyo | seancorfield: so to clear up a bit I what one function to update all values for keys I `select` and not one at a time |
| 18:21 | triyo | that `inc` could run for :id and :age in one pass/ |
| 18:21 | TeXnomancy | Raynes: I've never been one to pass up the opportunity to convince someone else to write code for me. |
| 18:21 | Raynes | Heh |
| 18:24 | Raynes | I liek it. |
| 18:25 | TeXnomancy | possibly worth suggesting for clojure.core/drop, but definitely need to percolate the idea a bit more first |
| 18:26 | Raynes | TeXnomancy: What is mouse-2 in Emacs? |
| 18:29 | seancorfield | triyo: (reduce #(update-in %1 [%2] your-fn) your-map [:id :age]) |
| 18:30 | seancorfield | Raynes: isn't that "right-click"? |
| 18:30 | TeXnomancy | it reads left-to-right |
| 18:30 | TeXnomancy | so left is 1, middle is 2, and right is 3 |
| 18:31 | Raynes | seancorfield: I thought so too, but I think it might be scroll button. |
| 18:31 | Raynes | Right. Damn. I need to figure out how to simulate that on a mac (with a trackpad). |
| 18:31 | TeXnomancy | or bind it to a key |
| 18:31 | Raynes | Or that, yes. |
| 18:32 | seancorfield | hmm, what's "middle button" on a mac??? |
| 18:32 | lazybot | seancorfield: Yes, 100% for sure. |
| 18:32 | Raynes | seancorfield: There isn't one, afaik. |
| 18:34 | Raynes | TeXnomancy: I can bind it to s-mouse-1! |
| 18:34 | Raynes | Slick. |
| 18:36 | seancorfield | s-... on a Mac is the command (splat) key, yes? |
| 18:36 | Raynes | Yes. |
| 18:37 | Raynes | s-mouse-1 is unbound and easily accessible. |
| 18:39 | seancorfield | i saw someone talking about syntax highlighting in the slime repl - what was the elisp magic for that? |
| 18:39 | seancorfield | (if it's even possible) |
| 19:12 | jsnikeris | is there a way to prime your REPL by always running a startup script? |
| 19:19 | Raynes | TeXnomancy, seancorfield: Oh man. It took me an hour to figure out how to do that. I ended up rebinding s-mouse-1 to flyspell-correct-word. I was trying to make s-mouse-1 exactly the same as mouse-2, but I gave up on that. |
| 19:25 | seancorfield | jsnikeris: I added code to ~/.lein/user.clj for startup stuff... |
| 19:25 | seancorfield | just so it auto-uses clojure.repl and clojure.java.javadoc if the project is clojure 1.3.0 or later |
| 19:26 | seancorfield | (for slime/swank repl sessions as i recall) |
| 19:33 | duck1123 | I prefer to have my run function launch a swank server in addition to it's other services. That way my swank session always has all the initialization it needs, and all of my namespaces have been loaded |
| 19:33 | duck1123 | but that's only if you're running a server of some sort |
| 19:39 | TeXnomancy | jsnikeris: set :repl-init to a namespace you want loaded |
| 19:42 | TeXnomancy | but yeah, duck1123's way could be more convenient |
| 20:50 | yellow | if I have a record (defrecord A [w x y z]) what is the best way to get a submap {:w _w :x _x}? |
| 20:50 | yellow | (from an instance of that record) |
| 21:07 | gfredericks | select-keys should work |
| 23:24 | mbac | if you (line-seq (io/reader filename)) have you leaked the file descriptor? |
| 23:32 | TeXnomancy | mbac: yeah, you need with-open |
| 23:48 | mbac | (with-open [r (io/reader filename)] (do-thing (line-seq r))) ? |