2012-10-13
| 00:17 | Sgeo | ivan, I think something like that already happened. So few new programmers capable of programming COBOL. |
| 00:20 | tomoj | I hope fn-> and fn->> appear along with cond-> |
| 00:20 | Sgeo | What would fn-> and fn->> do? |
| 00:21 | Sgeo | Also, I still want the thing that I called let-> |
| 00:21 | tomoj | well |
| 00:22 | tomoj | (defmacro fn-> [& forms] `#(-> % ~@forms)) |
| 00:22 | tomoj | but |
| 00:22 | tomoj | I guess #(-> %) is is OK |
| 00:22 | Sgeo | Ah |
| 00:23 | Sgeo | So, a macro that essentially does what comp does? |
| 00:23 | Sgeo | In reverse? |
| 00:23 | Sgeo | Except works with macros and never needing #() I guess |
| 00:23 | Sgeo | I guess it's the thrust vs -> debate again |
| 00:24 | tomoj | (fn-> (rename-keys kmap)) |
| 00:25 | tomoj | I went with #(rename-keys % kmap) instead |
| 00:25 | tomoj | for some reason #,% seem like eyesores to me |
| 00:25 | Sgeo | I don't know if your definition of fn-> might conflict with using #() inside the form, but that's easy to fix by using fn and an autogensym |
| 00:26 | ivan | gah Java has no NullOutputStream built in? |
| 00:26 | Sgeo | (defmacro fn-> [& forms] `(fn [arg#] arg# ~@forms)) |
| 00:26 | Sgeo | Erm, oops deleted the -> |
| 00:27 | Sgeo | (defmacro fn-> [& forms] `(fn [arg#] (-> arg# ~@forms))) |
| 00:27 | tomoj | yeah, it seems to break otherwise |
| 00:28 | tomoj | strangely it doesn't cause an error |
| 00:29 | tomoj | wait, no, it seems to work |
| 00:53 | aperiodic | what? it totally breaks without the gensym |
| 00:53 | aperiodic | you can't have fully-qualified symbols as parameters |
| 00:57 | Sgeo | I think I'm beginning to see a rationale behind the behavior of symbols in Clojure: It's slightly creepy for symbols to have magic information added to them on read |
| 01:08 | amalloy | ivan: welcome to the glory of java.io |
| 01:09 | amalloy | classes instead of interfaces, inheritance instead of composition, and no useful primitives |
| 01:10 | amalloy | Sgeo: using #() in a macro won't affect users of the macro, because #() is a reader macro |
| 01:10 | tomoj | aperiodic: hmm |
| 01:10 | ivan | anyone have some sort of Clojure thing to black-hole *out*? |
| 01:10 | tomoj | ,(defmacro fn-> [& forms] `#(-> % ~@forms)) |
| 01:10 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 01:11 | Sgeo | amalloy, ah, ok |
| 01:11 | tomoj | well, (= (macroexpand-1 '(fn-> inc)) (fn* [p1__5906__5907__auto__] (clojure.core/-> p1__5906__5907__auto__ inc))) |
| 01:11 | ivan | I guess I have to write a proxy if I want it in Clojure |
| 01:11 | Sgeo | black-hole? |
| 01:12 | tomoj | hmm |
| 01:12 | tomoj | (= (macroexpand-1 '(fn-> #(%))) (fn* [p1__5906__5907__auto__] (clojure.core/-> p1__5906__5907__auto__ (fn* [p1__5923#] (p1__5923#))))) |
| 01:16 | Sgeo | Um. |
| 01:16 | Sgeo | Does ClojureScript not have promises? |
| 01:17 | amalloy | Sgeo: who would deliver to them while you block the only thread waiting? |
| 01:17 | Sgeo | Could wait for one after it's delivered. e.g. using a promise to give an event handler the key to unregistering it |
| 01:19 | tomoj | in (let [a 3 b 4]), are the bindings ([a 3] [b 4]) or (a b)? what's the other one called? |
| 01:19 | amalloy | so? if you never block on it, a promise is just an atom that you only write to once; easily implementable yourself without language support |
| 01:20 | Raynes | ivan: https://www.refheap.com/paste/5065 something like this |
| 01:20 | Raynes | Not sure what class you have to proxy, but this is what it would look like. |
| 01:20 | Sgeo | I guess promises seem more semantically accurate somehow, or I'm used to thinking about the answer to that question in terms of promises |
| 01:21 | tomoj | you have to cps |
| 01:24 | tomoj | hmm |
| 01:24 | tomoj | so you would prefer (cps (let [x @async-promise] (+ x 3))) ? |
| 01:25 | tomoj | to, say, (cps (let [x async-promise] (+ x 3))) |
| 01:25 | ivan | Raynes: cool, thanks a lot |
| 01:25 | tomoj | I was looking at http://taskjs.org/ |
| 01:26 | tomoj | you have to explicitly yield (is that the opposite of deref?) for an async value |
| 01:26 | tomoj | can't decide whether that's good or bad |
| 01:26 | ivan | explict yields reveal switch points which is good if you want your programs to work |
| 01:26 | tomoj | switch points? |
| 01:26 | ivan | some mutable state could change between yields |
| 01:27 | ivan | bad #python terminology I'm reusing |
| 01:27 | tomoj | mutable state? :P |
| 01:27 | ivan | =) |
| 01:27 | tomoj | the point is to get rid of that.. |
| 01:27 | Sgeo | I think, as long as I can call some function that itself does yields, and expect it to work from within my own generator, I'm happy |
| 01:28 | tomoj | I haven't figured out yet whether task.js is sufficiently composable |
| 01:28 | Sgeo | I don't like the non-composibility I've been exposed to, where I can't abstract some lines that use yield into a function |
| 01:31 | Sgeo | Hmm, I don't have access to defmacro in Himera.... darn |
| 01:31 | Sgeo | Well, that makes sense, because there's no defmacro in ClojureScript |
| 01:31 | Sgeo | But that means I don't see a way to get the server to run arbitrary code >:( |
| 01:42 | shachaf | ivan: You're alive? |
| 01:49 | tomoj | if Named were a protocol, should java.util.UUID satisfy it? |
| 01:50 | ivan | shachaf: I'm alive |
| 01:50 | shachaf | Weird. |
| 01:52 | shachaf | Are you still in that place which isn't the bay area? |
| 01:52 | ivan | yep |
| 01:53 | shachaf | You should instead try being in that place which is the bay area. |
| 01:53 | shachaf | You should go to edwardk's talk next week! |
| 01:54 | tomoj | the incanter one? |
| 02:25 | bfreis | Hello, I've just posted a question on SO, I'd be glad if anyone could take a look and give a hand! http://stackoverflow.com/questions/12870437/override-drop-for-a-custom-sequence |
| 02:26 | bfreis | In short, I'm writing a custom seq that could be slow because it reads data (lazily) from disk, and I want to reimplement drop in a way that would avoid unecessary reads. |
| 02:30 | brainproxy | one of my deps is pulling in an older version of clj-stacktrace, but I can't figure out which one :/ |
| 02:31 | brainproxy | is there a way to have `lein deps` spit out more verbose info, i.e. so you can figure out which dep is responsible for triggering a download/install |
| 02:34 | tomoj | bfreis: strange, my implementation of drop seems to call more |
| 02:36 | bfreis | tomoj: indeed, I've just checked core.clj and (drop) does call (rest), which calls (more). But I'm not sure I understand what you mean. |
| 02:36 | bfreis | tomoj: I mean, my implementation of (more) calls (next), which will cause unecessary reads. |
| 02:37 | tomoj | yeah |
| 02:37 | bfreis | Oh, I see your point. |
| 02:37 | tomoj | the answer is "no" |
| 02:37 | bfreis | I could reimplement more in a way that it does not call next |
| 02:38 | bfreis | more would just drop cached items and increment the counter |
| 02:38 | bfreis | brilliant |
| 02:38 | bfreis | thanks! |
| 02:38 | tomoj | oh |
| 02:38 | tomoj | but it still will be O(n), yes? |
| 02:38 | bfreis | Yes |
| 02:39 | bfreis | Could be better, but this is already way better than the first workaround I could figure out. |
| 02:39 | bfreis | I will update the question |
| 02:39 | tomoj | isn't that what your next already does? |
| 02:40 | bfreis | My next reads data into the cache if necessary |
| 02:40 | bfreis | Oh, crap |
| 02:40 | bfreis | It won't work! |
| 02:40 | bfreis | If I (first (drop dataseq)), there would need to be some data available in the cache |
| 02:41 | bfreis | Damn, back to the original problem of my first workaround: I'd need some mutable state: a mutable cache to be populated by the first call to (first) |
| 02:41 | tomoj | well, you can return a lazy-seq ? |
| 02:42 | bfreis | Hmmm, would that help? How would that be different? |
| 02:42 | tomoj | ,(doc lazy-seq) |
| 02:42 | bfreis | You mean, replace load-data by something like (defn load-data [id] (lazy-seq .....)) |
| 02:42 | clojurebot | "([& body]); Takes a body of expressions that returns an ISeq or nil, and yields a Seqable object that will invoke the body only the first time seq is called, and will cache the result and return it on all subsequent seq calls. See also - realized?" |
| 02:42 | tomoj | no, put the next impl in more but wrap it in lazy-seq |
| 02:43 | tomoj | then make next (seq (.more this)) |
| 02:43 | tomoj | I think |
| 02:43 | tomoj | but really, you should be building an IChunkedSeq I think |
| 02:43 | tomoj | (if a seq at all..) |
| 02:44 | bfreis | But wouldn't that still have the same problem? A call to drop would just call more many times, reaching the "end" of the cache and causing a new read from the disk. |
| 02:44 | tomoj | the body of the (lazy-seq) is only evaluated when needed |
| 02:44 | bfreis | An IChunkedSeq? Hmmm, I think that could be worse: it could potentially cause unecessary reads |
| 02:45 | bfreis | (I'm trying to avoid reads because: if I read too little data, it is fast, but many small reads is much much slower than a big read; therefore I'm doing big reads, which are slow, and I'd like to avoid if not needed) |
| 02:45 | tomoj | I don't see why, you're already chunking |
| 02:46 | bfreis | Yes, but I'm controlling very precisely how I chunk my data |
| 02:46 | tomoj | that's what the IChunkedSeq interface would let you do |
| 02:46 | tomoj | maybe I'm confused |
| 02:46 | bfreis | Hmmm, I will take a look at it |
| 02:47 | bfreis | You said "if a seq at all", do you have another suggestion? |
| 02:47 | bfreis | I like it being a seq because I'm processing it with map, filter, partition-by, etc |
| 02:47 | tomoj | I was thinking of reducers |
| 02:47 | tomoj | but I don't think partition-by has been implemented |
| 02:47 | bfreis | reducers? o.O |
| 02:47 | tomoj | and might not fit |
| 02:47 | bfreis | What is that? |
| 02:48 | bfreis | I don't think I've ever read about it! |
| 02:48 | tomoj | http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html |
| 02:48 | tomoj | http://clojure.com/blog/2012/05/15/anatomy-of-reducer.html |
| 02:48 | tomoj | what are you doing with the seq? |
| 02:49 | bfreis | interesting! but I'm not sure it fits |
| 02:50 | bfreis | I'm filtering the data, I'm producing derived data by partitioning the original sequence and reducing the partitions |
| 02:50 | tomoj | well |
| 02:50 | tomoj | sounds like a good fit for reducers to me |
| 02:50 | tomoj | except http://dev.clojure.org/jira/browse/CLJ-991 |
| 02:50 | bfreis | :) |
| 02:50 | bfreis | damn |
| 02:51 | bfreis | I see that reducers do things with fork/join |
| 02:51 | bfreis | ie, in parallel |
| 02:51 | tomoj | those are called folders |
| 02:51 | bfreis | Would that help? I mean, I'm mostly IO bound |
| 02:51 | bfreis | oh |
| 02:52 | tomoj | but "reducers" I guess can mean "reducers and folders" |
| 02:52 | bfreis | oh, I see |
| 02:52 | tomoj | a reducer can be a good fit for IO because (unlike folders) it's a one-shot thing |
| 02:53 | tomoj | you make one reduce call to the reducer you built up with the IO reducer at the bottom, and it can e.g. open a file, make a pass through the data, then close it, then your reduce returns |
| 02:54 | tomoj | if you really want a seq, maybe seque could make your impl easier? |
| 02:54 | bfreis | hmmm, looks interesting, I will certainly take a look at reducers |
| 02:54 | bfreis | seque? never heard of it! |
| 02:54 | bfreis | ,(doc seque) |
| 02:54 | clojurebot | "([s] [n-or-q s]); Creates a queued seq on another (presumably lazy) seq s. The queued seq will produce a concrete seq in the background, and can get up to n items ahead of the consumer. n-or-q can be an integer n buffer size, or an instance of java.util.concurrent BlockingQueue. Note that reading from a seque can block if the reader gets ahead of the producer." |
| 02:55 | tomoj | not sure that helps, but it sounds vaguely similar to what you're doing |
| 02:55 | bfreis | indeed, good to know it exists, but I still think it wouldn't solve everything |
| 02:56 | bfreis | As I understand it, it would still need to read all the file |
| 02:56 | tomoj | your IndexedSeq has to read all the file, right? |
| 02:57 | bfreis | So, the reading would either: fill up my memory, or block until I read from que BlockingQueue to free some space |
| 02:57 | bfreis | Not necessarily, depends on how I will process it. Sometimes, yes, I need to fully read the file. Sometimes, no, I just want to drop a lot of data, process some data, drop more data, etc |
| 02:58 | tomoj | but doesn't your drop impl read everything as it goes? |
| 02:58 | bfreis | No, it would jump right to the position it would need to read |
| 02:59 | bfreis | (note that I'm not using an InputStream to read data, but a memory mapped file) |
| 03:00 | tomoj | how? more only steps through one at a time |
| 03:00 | bfreis | I mean, *if* I could override the default implementation of drop |
| 03:00 | tomoj | right, you can't :) |
| 03:00 | bfreis | damn :) |
| 03:02 | bfreis | well, I've got only two options left: to provide a (fast-drop [dataseq]) function, or to make my DataSeq even lazier, as I wrote on SO |
| 03:02 | bfreis | but I'd need to deal with mutable state, which I've never done in clojure |
| 03:02 | bfreis | (actually, I've tried it a bit, but in other contexts) |
| 03:03 | bfreis | tomoj, do you know if there's a reason we can't override drop? |
| 03:03 | bfreis | I mean, it is obvious that it can't be overriden, just by looking at core.clj |
| 03:04 | bfreis | But do you have an idea why this has been implemented that way, and not like (seq), (first), (next), etc? |
| 03:04 | bfreis | Is what I'm looking for *THAT* unusual? |
| 03:04 | tomoj | would you rather there be an IDrop interface? |
| 03:04 | bfreis | Exactly! |
| 03:05 | bfreis | Just like there's clojure.lang.Counted, which provides count() |
| 03:09 | tomoj | I don't think I can explain why that isn't the case |
| 03:09 | bfreis | There could be an IDrop interface, then drop (in clojure.core) would call RT.drop, which would check if the instance implements IDrop then call that method, otherwise would fallback to the default implementation that calls more n times |
| 03:09 | tomoj | except with a slippery slope argument :/ |
| 03:09 | bfreis | :P |
| 03:10 | tomoj | it looks like IChunkedSeq won't work in place of IndexedSeq either |
| 03:10 | tomoj | since drop isn't chunk-aware |
| 03:10 | tomoj | seems like it should be |
| 03:10 | tomoj | if it were you could have a chunked seq of counted chunks |
| 03:11 | bfreis | indeed |
| 03:11 | tomoj | and drop could just skip over chunks and they'd never be read |
| 03:11 | bfreis | but the thing is: |
| 03:11 | bfreis | I could have a chunked sequence built from "iterate". In this case, the intermediate, thrown away, elements, might need to be built |
| 03:12 | bfreis | Imagine a chunked version of the canonical implementation of fibonacci sequence using iterate |
| 03:12 | bfreis | (or something similar, but in which chunks make more sense) |
| 03:13 | bfreis | (map first (iterate (fn [[a b]] [b (+ a b)] [0 1])) |
| 03:13 | bfreis | (drop 1000000 fibs), that would need to calculate all the dropped fibs |
| 03:14 | tomoj | some chunked seqs might behave that way, but not all |
| 03:14 | bfreis | yes |
| 03:15 | bfreis | The one that started this discussion would tremendously benefit from drop being chunk-aware |
| 03:17 | tomoj | anyway I think reducers would be a good fit, but you'd need to copy the partition-by from the patch above. and defcurried and rfn from clojure probably, since they're private >:[. oh and reducers are only in 1.5.0-alpha4 |
| 03:17 | tomoj | er, alpha6 is the latest |
| 03:20 | tomoj | well, drop might still be problematic with reducers |
| 03:21 | tomoj | yeah, I think r/drop still would force reading everything |
| 03:21 | bfreis | :/ |
| 03:22 | bfreis | Do you think Rich would consider adding IDrop, RT.drop and modifying (drop), so that it would be similar to how (count) is implemented? |
| 03:22 | bfreis | *Rick |
| 03:22 | bfreis | RichHickey |
| 03:22 | bfreis | damn |
| 03:22 | tomoj | I would bet $50 he wouldn't |
| 03:23 | bfreis | :P |
| 03:23 | tomoj | (and I make $20K) |
| 03:23 | bfreis | lol |
| 03:23 | tomoj | but I think a patch to make drop chunk-aware could happen |
| 03:24 | bfreis | hmmmm |
| 03:25 | bfreis | And what's the standard way to suggest this? |
| 03:25 | bfreis | Is there any official "wish list"? |
| 03:29 | brainproxy | bfreis: the google discussion group |
| 03:30 | bfreis | brainproxy: thanks! |
| 03:30 | brainproxy | np |
| 04:18 | amalloy | it sounds like bfreis doesn't want to implement a seq, but something that's Indexed and just call nth on it for items he decides he actually wants |
| 04:18 | bfreis | amalloy: I usually do want a seq -- I process the data sequentially |
| 04:19 | amalloy | no you don't. you skip over it with drop |
| 04:20 | bfreis | sorry, amalloy, it is not you who is processing the data, it is me. |
| 04:20 | bfreis | Trust me: I'm telling you I process the data as a whole some times, and parts of it other times. |
| 04:21 | bfreis | I experimented with nth, but opening a file, reading 3 bytes and closing it becomes very slow when you need more than a few entries -- especially if I need sequential entries, which, again, believe me, is what I need. |
| 04:22 | bfreis | (and to be clear, when I say "parts of it" I mean: long runs of sequential data, not necessarily in the beginning of the file) |
| 04:25 | bfreis | Seriously, I hate when people act as they know what I'm doing more then I know what I'm doing. |
| 04:38 | samrat | I need to store username/password in a Noir session. What is the most secure way to do this? |
| 04:38 | samrat | just to be clear, the password is for another application's APi |
| 04:41 | bfreis | samrat: the decision on how to store that credentials depends on what you are trying to protect from. |
| 04:42 | bfreis | For instance, you could have a hardcoded "master key" to encrypt the credentials, and store that in a database. Then you read and decrypt it whenever you need. |
| 04:42 | bfreis | That way, if someone hacks into your database, the password won't be readable. |
| 04:42 | bfreis | However, if they have access to the source code (or the compiled code as well), they can obtain the master password. |
| 04:43 | bfreis | You could store that master key it into a file, but again, if they have access to the file, security is gone. |
| 04:44 | bfreis | You could have your application ask for the password at startup, so it would only be stored on your head. But I doubt you would like to type it everytime you launch your application |
| 04:44 | bfreis | (and, to be clear, there's still the possibility to read the password from memory) |
| 04:45 | bfreis | Anyways, the decision depends on what you are trying to protect from. |
| 04:46 | samrat | bfreis: I'd like to have a hardcoded master key, what are my options? |
| 04:47 | samrat | noir does provide noir.util.crypt but that just provides an option to compare against a raw password, and not fully decrypt it |
| 04:47 | bfreis | samrat: (def master-key "my-m4st3r-k3y") |
| 04:47 | bfreis | oh, I don't know noir.util.crypt |
| 04:47 | bfreis | I'm talking about general approachs to this kind of problem |
| 04:47 | samrat | bfreis: ok |
| 04:48 | samrat | do tell about the general approach |
| 04:49 | bfreis | Another option is to have a different key per user: you generate a random key and store it along with the user information. But again, if this key is stolen, the encryption is useless. |
| 04:49 | bfreis | You could encrypt the passwords with a combination of a master-key (either hardcoded, or typed on startup) and this random key. |
| 04:50 | bfreis | You could also avoid saving this user-key by deriving the key from the user data. |
| 04:50 | samrat | bfreis: any recommendations on encrypting libraries? |
| 04:50 | bfreis | Well, you have tons of options there, the decision really depends on the threats. |
| 04:50 | bfreis | samrat: javax.crypto already has a lot of useful classes |
| 04:51 | bfreis | samrat: if you need something else which is not provided in the standard distribution (for instance, GCM), you could try BouncyCastle |
| 04:53 | bfreis | http://www.bouncycastle.org/java.html\ |
| 04:53 | bfreis | http://www.bouncycastle.org/java.html |
| 04:53 | bfreis | But usually javax.crypto is enough |
| 04:55 | samrat | bfreis: is javax.crypto included in the standard distribution? |
| 04:56 | bfreis | samrat: yes |
| 04:57 | bfreis | In the book Programming Clojure, the authors use it to create a "crypto vault" |
| 04:57 | bfreis | someone published a lib based on that: https://github.com/midpeter444/crypto-vault |
| 05:02 | samrat | bfreis: I think I'll try using this https://github.com/macourtney/clj-crypto. crypto-vault seems to be specific to file encrypting |
| 05:03 | bfreis | Didn't know clj-crypto, looks interesting. |
| 05:04 | bfreis | It is a wrapper around on javax.crypto, using the BouncyCastle provider (I don't know why, apparently it could use the standard, built-in JCE) -- but I might have missed something |
| 05:05 | samrat | bfreis: I'll try it... but there's absolutely no docs, so might be a pain |
| 05:07 | bfreis | Oh |
| 05:07 | bfreis | be careful, though |
| 05:07 | bfreis | You will be doing symmetric encryption for this |
| 05:08 | bfreis | And that library uses DES as the standard algorithm |
| 05:08 | bfreis | But DES is considered very insecure nowadays |
| 05:10 | bfreis | Furthermore, he doesn't specify the mode and padding, therefore it should be DES/ECB/PCKS5Padding, which means: it is weak. |
| 05:11 | samrat | bfreis: yeah... I think it breaks with 1.4 or something, not working for me(it depends on 1.2) |
| 05:12 | samrat | any other wrappers for javax.crypto? I don't want to have to deal with java |
| 05:14 | bfreis | Sorry, I don't know. I haven't done much crypto in clojure, and when I did, I just used javax.crypto. |
| 05:34 | bfreis | tomoj: just posted the version of DataSeq using a mutable local cache updated by first to stop drop from reading from the disk! |
| 05:34 | bfreis | http://stackoverflow.com/a/12871794/150339 |
| 05:40 | samrat | how do I find the data type of something in clojurescript? (class ...) doesn't seem to work |
| 05:48 | bfreis | samrat: it looks like you'd profit from reading this http://blogs.msdn.com/b/ericlippert/archive/2011/09/27/keep-it-secret-keep-it-safe.aspx |
| 05:48 | bfreis | (I just came across that article and thought about what you are trying to do) |
| 05:49 | bfreis | it is a little bit long, but worth the time, from Eric Lipert |
| 05:54 | samrat | bfreis: thanks, will go through it |
| 08:26 | uvtc | ,(apply + 1 2 3) |
| 08:26 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long> |
| 08:26 | uvtc | ,(apply + 1 2 3 nil) |
| 08:26 | clojurebot | 6 |
| 08:26 | uvtc | Why does that second one work? |
| 08:26 | uvtc | There's still no seq to unpack (the contents of which `+` is applied to). |
| 08:34 | terom | ,(apply + 1 2 3 '()) |
| 08:34 | clojurebot | 6 |
| 08:35 | ssideris | hello. In clojurescript, do we throw exceptions as normal? |
| 08:35 | ssideris | I guess one has to stick to the Exception class |
| 08:36 | ssideris | because IllegalArgumentException does not exist |
| 08:36 | ssideris | correct? |
| 08:36 | andrewmcveigh | uvtc: because apply calls 'seq', and (seq nil) => nil ? |
| 08:36 | andrewmcveigh | ,(seq nil) |
| 08:36 | clojurebot | nil |
| 08:37 | terom | uvtc: only the last arg to apply should be a seq, other args before it are "added" to that seq: http://clojuredocs.org/clojure_core/clojure.core/apply#example_520 |
| 08:38 | uvtc | terom: right, I understand that. But I was under the impression that the last arg must be a coll. |
| 08:39 | AdmiralBumbleBee | uvtc: as far as I understand it, nil can be used anywhere a collection can (with obvious exceptions) |
| 08:39 | AdmiralBumbleBee | ,(concat [1 2 3] nil) |
| 08:39 | clojurebot | (1 2 3) |
| 08:39 | uvtc | In the source for `apply`, I see that call to `list*`. |
| 08:40 | uvtc | ,(list* 1 nil) |
| 08:40 | clojurebot | (1) |
| 08:40 | uvtc | So, that's it I suppose. |
| 08:41 | uvtc | ...since `list*` calls `cons`, and `cons` seems happy to cons onto `nil`. |
| 08:41 | uvtc | ,(cons 1 [1 2 3]) |
| 08:41 | clojurebot | (1 1 2 3) |
| 08:41 | uvtc | ,(cons 1 nil) |
| 08:41 | clojurebot | (1) |
| 08:42 | uvtc | AdmiralBumbleBee: That sounds odd. If it's the case, I wonder why that is. |
| 08:44 | AdmiralBumbleBee | uvtc: I'm not sure why at all, but I noticed it and so I tried lots of permutations of it and it seems to be practically correct… if not technically correct |
| 09:13 | nonrecursive | I'm trying to use weavejester's ragtime library but I keep getting this error: Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: clojure/lang/ILookupHost |
| 09:13 | nonrecursive | has anyone seen that? know how to fix it? |
| 09:23 | wting | Hi, can someone explain how this returns the last element of a list? reduce #(-> %2) |
| 09:25 | babilen | wting: It always returns the second argument to the function that is reduced with. That argument is the current element (the first is the accumulator/result) to which "f" is applied |
| 09:26 | babilen | wting: I would use (last coll) though ;) |
| 09:27 | wting | babilen: Thanks, doing 4clojure koans and last isn't allowed. :p |
| 09:27 | wting | The goal was to recreate last. |
| 09:27 | babilen | wting: Ah, sure. In that case: Have fun! |
| 09:28 | nonrecursive | How would I modify my project's dependencies so that I can debug an issue? For example, I'm using ragtime and would like to throw some println statements in it, but I don't know where the code is actually located |
| 09:29 | babilen | nonrecursive: You mean "throw some println statements [into ragtime]" ? |
| 09:30 | nonrecursive | yeah |
| 09:30 | nonrecursive | exactly :) |
| 09:32 | babilen | nonrecursive: If you use leiningen 1 you'll find dependencies in PROJECT/lib and if you use leiningen 2 you would find it in ~/.m2/repository/ -- You cannot edit those directly though. I would personalyl recommend to just get hold of ragtime, make your changes and "install" it with "lein install" to ~/.m2/ (if you use lein2) |
| 09:32 | babilen | nonrecursive: That assumes that ragtime doesn't provide any debug/loggin facilities itself that you can enable (e.g. by setting a dynamic variable somewhere in its namespace) |
| 09:32 | nonrecursive | babilen: thanks, that helps a lot. I'm using leiningen 2 - I'll try what you described |
| 09:33 | babilen | nonrecursive: ragtime is probably on github ... create a new local branch (e.g. dev/debug or whatev) so you can hack away. You might even want to change the version so you don't (by mistake) pick up the original. |
| 09:34 | nonrecursive | babilen: yeah it's on github - thanks for the tips |
| 11:35 | ticking | I was wondering what is the best way to append elements to a seq? |
| 11:37 | dnolen | ticking: concat, which is lazy. |
| 11:37 | dnolen | ,(concat '(1 2 3) '(4 5 6)) |
| 11:37 | clojurebot | (1 2 3 4 5 ...) |
| 11:44 | ticking | dnolen, thanks :) still kinda meh that one has to wrap the value first ;) |
| 11:45 | ddeaguiar | ticking: use cons if appending single value? Though that won't return a lazy seq. |
| 11:46 | dnolen | ddeaguiar: cons on a seq will add to the front |
| 11:46 | ticking | ddeaguiar, and conj will add to the front or back depending on the collection type |
| 11:46 | ddeaguiar | dnolen: ah yes, |
| 11:46 | ticking | (which drove me almost mad during debugging) |
| 11:46 | dnolen | ticking: or something else entirely. |
| 11:46 | ticking | dnolen, right ^^ |
| 11:47 | dnolen | ticking: since you conj on a set or a hash map too |
| 11:49 | ticking | thanks and see you :D |
| 12:34 | Bronsa | https://github.com/Bronsa/blind a complete clojure reader implemented in clojure |
| 12:34 | Bronsa | based on clojure's implementation and clojurescript's |
| 13:14 | lynaghk | ping: alex_baranosky |
| 13:15 | alex_baranosky | pong: lynaghk |
| 13:15 | alex_baranosky | :) |
| 13:16 | lynaghk | alex_baranosky: have any tips on how to speed up midje? I'm using 1.4.0 under lein2 with the lein-midje 2.0.0-SNAPSHOT |
| 13:16 | lynaghk | alex_baranosky: I'm getting the sense that it loads every dep in every namespace rather than just what's required by stuff in the test/ dir |
| 13:17 | alex_baranosky | speed up Midje on a per assertion basis? |
| 13:17 | lynaghk | alex_baranosky: nah, just the startup. I just threw it into this project and have two assertions |
| 13:17 | alex_baranosky | or speed up the load time? |
| 13:18 | alex_baranosky | your sense is correct: https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L119 |
| 13:19 | alex_baranosky | the reason is, I think, that some users put assertions in their source??? |
| 13:19 | lazybot | alex_baranosky: How could that be wrong? |
| 13:19 | lynaghk | alex_baranosky: okay, fair enough. I'll look into the lazytest solution then---is that still what's what? Sierra's project looks very unmaintained |
| 13:20 | alex_baranosky | the issue could be resolved by adding a option to only load the test-path |
| 13:21 | alex_baranosky | lynaghk: regarding lazy test…. not sure what's going on with that . I don't use it myself |
| 13:21 | lynaghk | alex_baranosky: you just run "lein midje" manually? |
| 13:22 | alex_baranosky | lynaghk: there's a midge mode that could probably help your situation too |
| 13:22 | lynaghk | alex_baranosky: yeah, I was thinking maybe I'd just primarily run tests from within emacs/swank |
| 13:23 | lynaghk | alex_baranosky: thanks for the info! |
| 13:24 | alex_baranosky | lynaghk: yeah try that, and if it doesn't work out, a pull request to lein-midje to narrow the namespaces loaded could be good |
| 13:24 | lynaghk | alex_baranosky: okay, can do. |
| 13:26 | alex_baranosky | lynaghk: it also looks like if you specify a namespace wilcdcard you'll avoid the issue |
| 13:26 | alex_baranosky | lynaghk: try this `lein midje my.project.test.*` (see: https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L133) |
| 13:27 | Bronsa | http://sprunge.us/KXEe?clj is this expected behaviour or is it a bug? |
| 13:28 | lynaghk | alex_baranosky: yeah, that's the first thing I tried but it didn't pick up my test |
| 13:28 | lynaghk | alex_baranosky: test is in /test/ccplot/t_compile.clj; namespace is ccplot.t-compile |
| 13:28 | alex_baranosky | lynaghk: dang. I wonder if there's a bug in it. The lein-midje stuff isn't tested (which I hate) |
| 13:28 | lynaghk | alex_baranosky: running "lein midje ccplot.*" doesn't find any facts |
| 13:29 | alex_baranosky | what about `lein midje ccplot.t_compile` ? |
| 13:30 | lynaghk | alex_baranosky: yep, that works |
| 13:31 | alex_baranosky | lynaghk: ….. so something's a-rye with the wildcard code |
| 13:32 | alex_baranosky | lynaghk: it should be getting the namespace-on-classpath, using multitude. (https://github.com/marick/lein-midje/blob/master/src/leiningen/midje.clj#L88) |
| 13:32 | alex_baranosky | ok have to go. Let me know if you have any more questions. Take it easy. |
| 13:32 | lynaghk | alex_baranosky: okay. thanks |
| 13:33 | lynaghk | alex_baranosky: I'll open a ticket. |
| 13:33 | alex_baranosky | lynaghk: oh, and any fixes or improvements are welcome |
| 13:50 | @rhickey | draft of the results from yesterday's cond-> discussion: https://gist.github.com/3885504 |
| 14:54 | zerokarmaleft | rhickey: in let->, expr and forms needs to match ~init and steps |
| 15:07 | tgoossens | if i have two lists. Is there a "built-in" way to check if those two lists have overlapping elements? |
| 15:09 | egghead | tgoossens: if they are sets you can use intersection |
| 15:09 | frozenlock | If you don't mind using sets, there's quite a few interesting functions. |
| 15:09 | frozenlock | Aww |
| 15:09 | tgoossens | they are sets. But i'm also interested in the "general" way for a list |
| 15:11 | frozenlock | I was sure that 'if' would not evalutate before it needed to, but I have an 'if' function that lookups in a database even if it only needs to go to the else statement. |
| 15:11 | frozenlock | How can I avoid evaluation? |
| 15:12 | ChongLi | you can't do it with a function |
| 15:13 | ChongLi | you need a macro |
| 15:13 | egghead | (if true (println true) (println false)) <-- in that you're saying the 'println false' is evaluating? |
| 15:13 | frozenlock | yeah |
| 15:14 | frozenlock | More precisely: (if login (query-database-for-stuff) (print-some-msg)) |
| 15:14 | frozenlock | And in my case even if login is false, the database is queried. (and throws an error) |
| 15:16 | egghead | weird, according to the clojure docs if shouldn't evaluate the "then" form if the value of the test is falsy |
| 15:18 | frozenlock | That was my original impression too. |
| 15:19 | egghead | also tgoossens you can filter down any one list by whether or not each member is within the other list using filter and contains? -- probably not super effecient tho :p |
| 15:20 | ChongLi | he's talking about an 'if' function |
| 15:20 | egghead | err wait |
| 15:20 | raek | frozenlock: are you sure 'login' really is false? |
| 15:20 | ChongLi | that presumably he wrote |
| 15:20 | egghead | contains wouldn't work |
| 15:20 | ChongLi | the real 'if' is not a function |
| 15:21 | @rhickey | zerokarmaleft: thanks, hasty rename before gifting - fixed |
| 15:21 | @rhickey | gisting |
| 15:21 | frozenlock | raek: I am, I've hardwritten false in it. Let me try to get a minimum working example... |
| 15:23 | KaOSoFt | rhickey, sorry to hijack, but any reason there a “reduce1” function? Sorry, I’m new to Clojure, but found it weird to find a “reduce1” function inside +, -, etc. |
| 15:24 | KaOSoFt | there is* |
| 15:25 | ChongLi | it's used internally before protocols are up and running |
| 15:25 | @rhickey | KaOSoFt: reduce gets redefined mid bootstrap |
| 15:27 | frozenlock | Damnit. I'm such an idiot. |
| 15:27 | frozenlock | Let see if you can see it too :P https://www.refheap.com/paste/5826 |
| 15:28 | frozenlock | ChongLi: I will probably have to make a macro as you suggested |
| 15:30 | Cubic | Why is [] true and (seq []) false? I find this somewhat confusing. |
| 15:31 | ChongLi | everything is true except nil or false |
| 15:31 | ChongLi | seq returns false |
| 15:32 | Cubic | ,(println (seq [])) |
| 15:32 | clojurebot | nil |
| 15:32 | ChongLi | ah yeah |
| 15:32 | Cubic | Oh. Well that makes sense |
| 15:32 | ChongLi | anyway, it makes easier to use it as part of a control structure for operation on seqables |
| 15:33 | Cubic | ,(for [x nil] true) |
| 15:33 | clojurebot | () |
| 15:53 | tgoossens | egghead: thanks |
| 16:50 | yedi | /join #economics |
| 17:02 | wingy | hi |
| 17:03 | wingy | how do you create mobile and tablet apps? |
| 17:06 | Cubic | For what mobile and for what tablets? |
| 17:07 | wingy | all of them |
| 17:08 | Cubic | Then deploy it as a web application |
| 17:09 | wingy | Cubic: i mean you do YOU do |
| 17:09 | wingy | i know there are different solutions |
| 17:10 | wingy | part of me things that native apps is an evolution and we will move away from HTML as native apps |
| 17:10 | wingy | thinks |
| 17:10 | Cubic | wingy: Isn't it pretty much the other way round? |
| 17:11 | wingy | after doing some research i found that native apps are really much more mature than html5 .. we always find a lot of inconsistencies using html5 |
| 17:11 | wingy | all those frameworks abstracting away the bad parts |
| 17:11 | wingy | perhaps the foundation is wrong? just like mutable states |
| 17:12 | wingy | reminds me about why we love OOP .. since it hides the complexity |
| 17:12 | Cubic | wingy: I don't understand your problem |
| 17:12 | AdmiralBumbleBee | his problem is that he talks in here about this stuff rather than #programming |
| 17:13 | wingy | it was on purpose since i wanted to know how clojure people do it .. here people tend to focus on simplicity |
| 17:13 | Cubic | wingy: So your question isn't about Clojure then? |
| 17:14 | wingy | you could say it is if you look at it from a higher perspective where clojure is part of it |
| 17:14 | Sgeo | Always writing native apps means needing to write several times for each platform |
| 17:14 | Sgeo | Even things like Java are abstracting away the annoyances of writing code for multiple platforms |
| 17:15 | Sgeo | And a lot of the reason for inconsistencies with HTML5 is that not everything supports it yet |
| 17:15 | Sgeo | Well, at least some of the reason |
| 17:15 | clojurebot | the reason to use the immutable types is that it saves you from all that stuff; if you don't use them you don't get the benefit. |
| 17:16 | Cubic | What's wrong with clojurebot? |
| 17:18 | wingy | Sgeo: you have a point |
| 17:18 | Sgeo | I wouldn't say that HTML5 is in fact "good", but relative to the alternative of developing native apps for everything... |
| 17:19 | wingy | Sgeo: there is a point in whaty ou way |
| 17:19 | wingy | say |
| 17:20 | wingy | that would be like developing for different platforms on server side |
| 17:26 | antares_ | ivan: are you gsnewmark on github? |
| 17:26 | TimMc | Cubic: clojurebot treats random messages as being addressed to it. |
| 17:26 | antares_ | man, the progress on CDS makes me all warn and fuzzy inside |
| 17:27 | antares_ | in just a week we have like more than half of the guides in decent shape |
| 17:27 | antares_ | and a dozen of contributors |
| 17:36 | oich | Do I simply ignore the throws clause of interfaces/classes when creating a proxy? Or, how does one specify a throws clause? |
| 17:36 | antares_ | oich: Clojure compiler ignores checked exceptions |
| 17:38 | oich | thanks |
| 17:47 | Raynes | antares_: ping |
| 17:48 | antares_ | Raynes: pong |
| 17:49 | Raynes | antares_: The Emacs tutorial on clojure-doc.org uses lein-clojars. If I want to point that out but not fix it right now myself, should I open an issue? |
| 17:50 | Raynes | I'm also a little bugged that it focuses on SLIME instead of nrepl.el just because of clojure-test-mode, but to a lesser extent. |
| 17:50 | antares_ | Raynes: yes, please. Just mention why you think it is a bad idea and what's a better way. |
| 17:50 | antares_ | Raynes: nrepl.el does not support clojure-test-mode |
| 17:50 | antares_ | that's discussed in the pull request, take a look |
| 17:50 | antares_ | well, that's exactly why I still use SLIME, for example |
| 17:51 | Raynes | I guess I don't know what clojure-test-mode is. |
| 17:51 | antares_ | when you hit C-c C-, in a test namespace and it runs your tests instantly |
| 17:52 | Raynes | I'm tempted to think most new users aren't going to care either and would rather have something more future-proof than SLIME. Especially common lisp users who would almost certainly rather trade clojure-test-mode for keeping their SLIME installation working for CL. |
| 17:52 | antares_ | Raynes: it very much depends on their background |
| 17:52 | antares_ | Raynes: what % of people come from CL vs Ruby? |
| 17:52 | antares_ | Ruby developers coming to clojure will certainly ask "how do I run tests quickly without JVM restarts" |
| 17:52 | Raynes | I'd be more interested in what percentage actually use clojure-test-mode though. |
| 17:53 | antares_ | Raynes: almost every person coming from Ruby, I think |
| 17:53 | Raynes | I find that hard to believe. |
| 17:54 | antares_ | people who don't use clojure-test-mode typically don't know about it |
| 17:54 | Raynes | Anyways, I'm not going to argue against it. I just hope people get clojure-test-mode going with nrepl fast, because I die a little inside every time we recommend SLIME to a new user. |
| 17:54 | antares_ | because nothing in the Clojure ecosystem is documented for noobs or visible |
| 17:54 | Raynes | Nobody likes providing support for that crap. |
| 17:54 | antares_ | me and Gareth hope so too :) |
| 18:01 | antares_ | Raynes: please do file issues for everything you don't like on CDS. I absolutely do not think that what we have right now is great. |
| 18:02 | antares_ | Raynes: also, we need a new ground for arguing |
| 18:02 | Raynes | Hah |
| 18:02 | AdmiralBumbleBee | wait, is CDS meant to be general documentation? |
| 18:02 | Raynes | Yeah, I figure the clojure-test-mode stuff is too subjective to make an issue for. |
| 18:03 | AdmiralBumbleBee | or is it an introduction to clojure for a certain population of people |
| 18:03 | Raynes | It's an easy fix -- someone just needs to care enough to make clojure-test-mode work with nrepl. |
| 18:06 | antares_ | AdmiralBumbleBee: it is primarily for newcomers but yes, it will cover most or even all expertise levels |
| 18:06 | antares_ | and not just the language |
| 18:06 | antares_ | there is value in simply centralizing and maintaining docs in one place |
| 18:08 | AdmiralBumbleBee | antares_: I'm somewhat perplexed why you'd consider someone's background when writing documentation. Certainly there's some pre-requisite knowledge required |
| 18:08 | AdmiralBumbleBee | but I would think that well written documentation would not need to cater to someone who knew python v ruby v C v CL etc.. |
| 18:09 | AdmiralBumbleBee | I do understand that there's a place for such targeted information, but in context of emacs+clojure it sounds weird to me for that to be a consideration |
| 18:10 | antares_ | AdmiralBumbleBee: well, you develop using some kind of tools, right? |
| 18:10 | AdmiralBumbleBee | of course |
| 18:10 | antares_ | Emacs is a popular choice when it comes to Clojure |
| 18:10 | AdmiralBumbleBee | yes, and I'm an emacs user for a long time |
| 18:12 | AdmiralBumbleBee | antares_: I'm just a bit perplexed as to why a reader's background should be considered when writing general documentation |
| 18:13 | antares_ | AdmiralBumbleBee: not sure I am following |
| 18:13 | antares_ | you cannot please everybody with a single approach to docs |
| 18:13 | AdmiralBumbleBee | ok, I'm probably explaining myself badly |
| 18:13 | antares_ | but that's why we are grouping things into Tutorials, Language Guides, Ecosystem and Cookbooks |
| 18:15 | AdmiralBumbleBee | antares_: I think lust I'm sensitive to you bringing up what a Ruby user would want to see in documentation :) I've brought that up before, so I'm restating myself I suppose. |
| 18:15 | AdmiralBumbleBee | just* |
| 18:15 | Raynes | antares_: I think he is referring to your response to my questions regarding clojure-test-mode that indicated a believe that everyone from Ruby uses it and most people probably come from Ruby so /thread. :p |
| 18:15 | Raynes | belief* |
| 18:21 | oich | can you invoke more than one constructor with proxy, i.e. the class a proxy is proxying for has more than one constructor |
| 18:23 | yedi | anyone have suggestions for a great clojure dev environment on osx? |
| 18:23 | AdmiralBumbleBee | yedi: emacs |
| 18:23 | lpvb | or CCW |
| 18:23 | antares_ | Raynes: everybody who comes from Ruby will expect it, that's what I really mean |
| 18:23 | antares_ | Raynes: and The State of survey suggests a good third of people come from ruby or python |
| 18:24 | antares_ | yedi: Emacs, Vim, Eclipse and IDEA are all pretty good |
| 18:24 | lpvb | vim doesn't have autocomplete :( |
| 18:25 | AdmiralBumbleBee | vim is a pain to setup on OS X in my experience |
| 18:25 | AdmiralBumbleBee | for clojure ^ |
| 18:28 | oich | to answer my question about multiple constructors, I think I can't use proxy and have to use gen-class |
| 18:30 | JonasH_ | AdmiralBumbleBee: true, I'm was just trying to get VimClojure working |
| 18:30 | JonasH_ | only semisuccessful so far |
| 18:31 | JonasH_ | can't get the key mappings to work |
| 18:31 | AdmiralBumbleBee | CCW or emacs can be setup on os x in about 3-4 minutes on a standard OS X install |
| 18:31 | AdmiralBumbleBee | vimclojure… eh :) |
| 18:31 | Sgeo | What's this about Ruby? |
| 18:31 | Sgeo | I've had some interest in it, but I could never shake the impression that, if I'm using Ruby, I should really be using Smalltalk instead |
| 18:32 | AdmiralBumbleBee | Sgeo: not talking about ruby… talking about documentation |
| 18:37 | ivaraasen | strange, clojure-doc.org doesn't seem to be working here |
| 18:44 | aperiodic | i'm using vim for clojure on os x w/slimv and bits of vimclojure |
| 18:44 | aperiodic | had a few stumbles setting it up, but works great now |
| 18:44 | aperiodic | i've also heard good things about vimclojure + lein-tarsier to handle the nailgun stuff |
| 18:58 | antares_ | ivaraasen: can you ping and dig it? where you located? |
| 19:10 | ivaraasen | antares_: getting req timeouts. situated in Norway |
| 19:11 | antares_ | ivaraasen: surprising, it is hosted in Germany |
| 19:11 | antares_ | ivaraasen: for dig, too? |
| 19:11 | antares_ | (ping's ICMP packets may be filtered out, actually) |
| 19:15 | ivaraasen | antares_: gives me back 5.9.20.53 as the IP address. |
| 19:15 | antares_ | ivaraasen: that's the correct answer |
| 19:15 | antares_ | ivaraasen: try traceroute-ing that IP? |
| 19:16 | ivaraasen | no route to host |
| 19:16 | ivaraasen | this is extremely weird |
| 19:16 | antares_ | ok, something must be up with one of the routing tables between your ISP and the hoster I use |
| 19:17 | ivaraasen | my ISP is notorious for screwing things up, so you're probably correct |
| 19:18 | ivaraasen | I'll give them a call tomorrow to see what's up |
| 19:21 | Urthwhyte | Any recommendations for a CSV processing lib? |
| 19:23 | amalloy | oich: proxy doesn't create a named class, it creates an instance of an anonymous class. you can only ever call one constructor at a time, so why would there be two? |
| 19:29 | frozenlo` | Urthwhyte: clojure-csv? :p |
| 19:31 | Urthwhyte | frozenlo`: Thanks :) I've spent enough time dealing with horrible ruby/python libraries that happened to rank well for search terms that I usually ask first now :) |
| 19:43 | mint` | hello :) question: I just ran lein for the first time on a live linux installation (which supports persistence) and jack-in is not an available task. what should i do differently? |
| 19:43 | technomancy | mint`: you need the lein-swank plugin |
| 19:43 | technomancy | or nrepl.el |
| 19:43 | mint` | ah |
| 19:47 | mint` | technomancy: what do i need to do after i install the nrepl emacs package? |
| 19:48 | technomancy | M-x nrepl-jack-in should do it |
| 19:49 | mint` | cool thanks! |
| 20:06 | ticking | lol, I wanted to implement partition-between, which is similar to partition-by but allows for arbitrary splits instead for value changes, turns out my slightly optimized implementation can do more than partition-by and is still faster |
| 20:14 | amalloy | ticking: https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L222 |
| 20:15 | ticking | amalloy ah cool, I asked a few days ago nobody pointed me to that :D I be mine is till faster though ;] I'll do a benchmark |
| 20:16 | amalloy | *shrug* it probably is. i don't see that it matters much either way |
| 20:16 | AdmiralBumbleBee | amalloy: what is this magic!? this need to be in core |
| 20:16 | AdmiralBumbleBee | everything here |
| 20:16 | ticking | amalloy, yeah but for core functions speed is significant |
| 20:31 | Sgeo | Should I rely on two different (Object.)s not being = in my programs? |
| 20:32 | Sgeo | Come to think of it, I could probably just use a symbol |
| 20:32 | technomancy | yeah, gensym is usually nicer IMO |
| 20:33 | amalloy | i usually use (Object.) |
| 20:33 | Sgeo | Good point, but I don't even need a unique object, not sure why I thought I did |
| 20:48 | ticking | so if anybody is interested, suggestions are welcome :) |
| 20:48 | ticking | https://gist.github.com/3886665 |
| 20:49 | clj_newb_234 | dumb question ... in clojre, how do I turn an character to a integer? i.e. \a -> 65 |
| 20:49 | ticking | clj_newb_234 int |
| 20:49 | clj_newb_234 | , (int \a) |
| 20:49 | clojurebot | 97 |
| 20:49 | clj_newb_234 | , (int \A) |
| 20:49 | clojurebot | 65 |
| 20:50 | clj_newb_234 | ah, cool; thanks :-) |
| 20:50 | ticking | np :) |
| 20:57 | Sgeo | ,(char 65) |
| 20:57 | clojurebot | \A |
| 20:58 | clj_newb_234 | is ther a clojure builtin (extract-hashmap hashmap keys) <-- it takes hashmap, but only the [k v ] pairs where k \in keys ? |
| 20:59 | Sgeo | ,(for [i (range 1000) :when (not= ((comp int char) i) i)] i) |
| 20:59 | clojurebot | () |
| 20:59 | Sgeo | Hmm, should probably have written that in terms of maps and filters |
| 20:59 | Sgeo | meh |
| 21:00 | uvtc | But how do you turn a one-character string into a char? I see that this ##(first (seq "a")) works ... |
| 21:00 | lazybot | ⇒ \a |
| 21:00 | Sgeo | ,(.charAt "a" 0) |
| 21:00 | clojurebot | \a |
| 21:01 | Sgeo | ,(first "a") |
| 21:01 | clojurebot | \a |
| 21:01 | Sgeo | ,(nth "a" 0) |
| 21:01 | clojurebot | \a |
| 21:01 | uvtc | Oh, of course, Sgeo. Right. :) |
| 21:01 | Sgeo | ,("a" 0)] |
| 21:01 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn> |
| 21:01 | uvtc | ,(last "a") |
| 21:01 | clojurebot | \a |
| 21:01 | Sgeo | ,(get "a" 0) |
| 21:01 | clojurebot | \a |
| 21:01 | Sgeo | ,(get "a" 1 :oops) |
| 21:01 | clojurebot | :oops |
| 21:02 | Sgeo | ,(get "a" 1) |
| 21:02 | clojurebot | nil |
| 21:02 | uvtc | I'd figured that `char` would do it, but `char` only takes an int. |
| 21:02 | Sgeo | ,(nth "a" 1) |
| 21:02 | clojurebot | #<StringIndexOutOfBoundsException java.lang.StringIndexOutOfBoundsException: String index out of range: 1> |
| 21:02 | Sgeo | ,(nth "a" 1 :oops) |
| 21:02 | clojurebot | :oops |
| 21:02 | Sgeo | Hrm. |
| 21:02 | Sgeo | ,(nth {:a 1} :a) |
| 21:02 | clojurebot | #<ClassCastException java.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.lang.Number> |
| 21:02 | AtKaaZ | how do you turn a string into a list of chars? |
| 21:03 | uvtc | ,(seq "hello") |
| 21:03 | clojurebot | (\h \e \l \l \o) |
| 21:03 | AtKaaZ | lol i was afraid of that, thanks |
| 21:03 | Sgeo | ,((comp type seq) "hello") |
| 21:03 | clojurebot | clojure.lang.StringSeq |
| 21:03 | Sgeo | ,((comp class seq) "hello") |
| 21:03 | clojurebot | clojure.lang.StringSeq |
| 21:03 | AtKaaZ | I remember hickey saying strings are sequences |
| 21:03 | AdmiralBumbleBee | afraid of that? |
| 21:04 | AtKaaZ | not afraid, but more like guessing/hoping |
| 21:04 | AdmiralBumbleBee | ah |
| 21:05 | Sgeo | ,(((partial partial apply) concat) [[1 2 3] [4 5 6]]) |
| 21:05 | clojurebot | (1 2 3 4 5 ...) |
| 21:06 | AdmiralBumbleBee | Sgeo: ? |
| 21:06 | uvtc | He's partial to `partial`. |
| 21:07 | uvtc | (er, sorry -- just guessed gender there, Sgeo) |
| 21:08 | AdmiralBumbleBee | uvtc: maybe just as insulting to say you couldn't tell he was male ;) |
| 21:08 | AdmiralBumbleBee | (assuming 'he' is of course… heh) |
| 21:08 | AdmiralBumbleBee | quick, we need a gender abstraction! |
| 21:08 | xeqi | they |
| 21:09 | uvtc | s/he is in the `s` namespace... |
| 21:09 | Sgeo | e |
| 21:09 | amalloy | Sgeo: type is mostly obsolete now |
| 21:09 | amalloy | (the clojure function, not the concept, of course) |
| 21:09 | Sgeo | I'm partial to Spivak pronouns, because nomics tend to use them a lot, and I grew up interested in nomic |
| 21:10 | Sgeo | I am a guy |
| 21:10 | uvtc | amalloy: do you mean the concept of "type", or the function `type`? Or both? |
| 21:10 | uvtc | amalloy: and if either, why is it (or they) obsolete? |
| 21:10 | amalloy | uvtc: BAM! ninja'd |
| 21:11 | Sgeo | (partial apply blah) returns a version of blah that accepts a seq instead of a variable number of arguments |
| 21:11 | amalloy | <amalloy> (the clojure function, not the concept, of course) |
| 21:11 | Sgeo | So, if I want a general function to turn functions that accept varargs into functions that accept seqs, I want (partial partial apply) |
| 21:11 | uvtc | amalloy: why is the Clojure function `type` mostly obselete? |
| 21:12 | Sgeo | amalloy, am I insane for liking partial partial stuff? |
| 21:12 | amalloy | it's a holdover from the days before deftype and defrecord, when the only way to introduce new types was the convention of putting :type :mytype in the metadata of your object |
| 21:13 | amalloy | Sgeo: no, i like partial partial apply myself. i had convinced ninjudd to add it to useful but then he changed his mind |
| 21:13 | Sgeo | ,(type ^{:type :foobar} 5) |
| 21:13 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Metadata can only be applied to IMetas> |
| 21:13 | amalloy | (def ap (partial partial apply)) (map (ap concat) coll) |
| 21:13 | uvtc | amalloy: thanks! |
| 21:13 | Sgeo | ,(type ^{:type :foobar} 'foo) |
| 21:13 | clojurebot | clojure.lang.Symbol |
| 21:14 | amalloy | ,(type (with-meta 'foo {:type :foobar})) |
| 21:14 | clojurebot | :foobar |
| 21:14 | Bronsa | wow |
| 21:14 | amalloy | ,(type '^{:type :foobar} foo) |
| 21:14 | clojurebot | :foobar |
| 21:15 | Sgeo | Wait, what's with the '^ |
| 21:16 | uvtc | amalloy: Heh, I see. Missed your comment ("ninja comment"). :) |
| 21:16 | Bronsa | I'm guessing the reader that way is quoting the symbol foo after metadata has been attached to it |
| 21:16 | Bronsa | whether using ^{}' the metadata is being attached to the form (quote ..) |
| 21:16 | amalloy | indeed, Bronsa |
| 21:31 | AtKaaZ | what should I look into if I wanted to read/process binary files into structs or something like that ? |
| 21:33 | AtKaaZ | this seems to be it right? https://github.com/ztellman/gloss/wiki/Introduction |
| 21:33 | amalloy | yes |
| 22:27 | AtKaaZ | CompilerException java.lang.RuntimeException: Unable to resolve symbol: in this context, compiling:(quil/core.clj:1) |
| 22:28 | AtKaaZ | how can I track down what's happening? |
| 22:31 | AtKaaZ | this is the file: https://github.com/quil/quil/blob/master/src/quil/core.clj |
| 22:34 | AtKaaZ | ,(seq " ") |
| 22:34 | clojurebot | (\space \ \space) |
| 22:34 | AtKaaZ | ,(seq " ") |
| 22:34 | clojurebot | (\space \) |
| 22:35 | AtKaaZ | ,,(int \) |
| 22:35 | clojurebot | 65279 |
| 22:37 | AtKaaZ | wow seriously, this is how that file begins: (ns |
| 22:41 | antares_ | AtKaaZ: this is UTF-8 BOM |
| 22:42 | antares_ | most likely that file was saved from a weirdly configured editor, possibly on Windows |
| 22:42 | AtKaaZ | that makes sense, but still not even github diff can show that char |
| 22:43 | AtKaaZ | look how it (doesn't look: https://github.com/quil/quil/commit/d0312f0f119db066a8d613dec8803571b92bea39 |
| 22:43 | AtKaaZ | :) |
| 22:44 | AtKaaZ | my concern is how to prevent that in the future? |
| 23:25 | ChongLi | ok I'm really confused |
| 23:25 | ChongLi | I have 2 different projects |
| 23:25 | ChongLi | with nearly identical project.clj |
| 23:25 | ChongLi | (same dependencies) |
| 23:26 | ChongLi | one of them can import a class at the repl |
| 23:26 | ChongLi | and the other gets UnsatisfiedLinkError |
| 23:26 | ChongLi | > (import org.lwjgl.opengl.Display) |
| 23:26 | ChongLi | org.lwjgl.opengl.Display |
| 23:27 | ChongLi | > (import org.lwjgl.opengl.Display) |
| 23:27 | ChongLi | UnsatisfiedLinkError no lwjgl in java.library.path... |
| 23:33 | ChongLi | when I print the classpath for both with (pprint (seq (.getURLs (java.lang.ClassLoader/getSystemClassLoader))) |
| 23:33 | ChongLi | it is virtually identical between the two (only the local project stuff differs) |
| 23:41 | ChongLi | ahh, hmm |
| 23:41 | ChongLi | target is different (native stuff in one but not the other) |