This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-09-18
Channels
- # aleph (45)
- # aws (4)
- # beginners (56)
- # boot (2)
- # cider (45)
- # clara (2)
- # cljs-dev (9)
- # cljsrn (31)
- # clojure (71)
- # clojure-dusseldorf (8)
- # clojure-gamedev (1)
- # clojure-italy (22)
- # clojure-nl (1)
- # clojure-russia (46)
- # clojure-sg (1)
- # clojure-spec (5)
- # clojure-uk (40)
- # clojurescript (30)
- # community-development (3)
- # cursive (17)
- # data-science (1)
- # datomic (18)
- # emacs (3)
- # figwheel (1)
- # fulcro (19)
- # hoplon (12)
- # jobs (5)
- # leiningen (42)
- # off-topic (12)
- # om (2)
- # onyx (41)
- # re-frame (19)
- # ring-swagger (1)
- # rum (3)
- # shadow-cljs (4)
- # specter (7)
- # unrepl (2)
- # vim (25)
- # yada (24)
Decomposing the call chain into a series of steps like this has a lot of benefits: you're more likely to separate side-effects from pure computation this way so more of your functions are likely to be pure which makes testing easier -- as well as offering more possibilities of reuse and making it easier to change just one step without changing any other code.
@didibus That makes sense to me. I take it from your example you read the section in question. I hope you dont mind that i linked to you comment on the google mailing list for the book. I did it before I caught myself and realized you might not want it me to. 😞. Zach seems a pretty chill guy, i’m not worried about that. I’m just not in the habit of quoting people without asking. I think your observation is a good one and i think Zach would want the feedback. I’m sure he has thought it through it but i’m not fully understanding the idea, sense as you point out, their seem to be alternatives. Maybe the feedback will lead to a concise explanation. BTW i really enjoy this kind of introspection, I get pretty caught up in worrying about choices like this and being able to chat about it gives me lot of insight and confidence. 😄 . Some of these concepts like Dynamic Vars are a bit fringe and haven’t really come up in the toy problems i have solve with Clojure. So
I don't mind. I actually haven't read the book in question. I'm just going off from what you said here. So I can't speak to what Zach mentions, and if it applies or not. This is just my general design recommendation. BTW, if you are interested in this level of design aspects, I highly recommended reading: https://smile.amazon.com/Exercises-Programming-Style-Cristina-Videira/dp/1482227371
Thanks. I’ll pick it up.
If you didn’t read the book, how did you know the option was turbo-mode?
. Is that a common option?
hi, can anyone advise me on how to write a transformation (s1 s2 s3)
=> {"s1" s1 "s2" s2 "s3" s3}
where in practise the length of the list is not known
(into {} (map-indexed (fn [idx v] [(str "screen_" idx) v]) (filter #(= (:type %) "screen") snippets)))
I'm using atom and repl and ran
(use 'figwheel-sidecar.repl-api)
(start-figwheel!)
(cljs-repl)
earlier today. Then I restarted things but I can't rerun the above because portt 3448 is in use. How can I restart the repl in atomHi all, a newbie question here, what would be the Clojure way of organizing a module tree like this one (Haskell)?
|- Foo.hs
|- Foo/
|- Bar.hs
|- Baz.hs
the idea is that Foo
contains the api for something that have two different implementations Bar
and Baz
You could use a protocol https://clojure.org/reference/protocols in Foo, and have several implementations of that protocol I think. Never used them myself.
ok this is wierd
Unhandled java.lang.IllegalArgumentException
No matching method found: main for class java.lang.Class
but when i list methods in object
i have main listed public static
how could this be that i cant call something that's available?@lepistane can you share your code please?
@hmaurer sure. i used https://pdfbox.apache.org/2.0/commandline.html#extracttext saw there is https://github.com/StankovicMarko/pdfboxing wanted to contribute and make function that does exactly that, i dug little bit inside saw i cant make it work, it got too complicated. Then i thought why not just use tool that already exists just make clojure wrapper function around that this is my code
(defn pdf-to-html [pdf-doc]
(.main ExtractText "-html" pdf-doc))
@lepistane main
is likely a static method. check this out https://clojure.org/reference/java_interop
@hmaurer it is static method but when i use (Classname/staticMethod args*)
from that link i get
Caused by java.lang.IllegalArgumentException
No matching method: main
@lepistane what about (ExtractText/main ["-html" pdf-doc])
?
ClassCastException clojure.lang.PersistentVector cannot be cast to [Ljava.lang.String; pdfboxing.text/pdf-to-html (form-init7626843526357124578.clj:51)
@lepistane (ExtractText/main (to-array ["-html" pdf-doc]))
?
@hmaurer havent tried this one
Unhandled java.lang.ClassCastException
[Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
Or maybe just (ExtractText/main "-html" pdf-doc)
?
doing guesswork here; I am new to Clojure myself. If someone knowledgeable is around please do interrupt me 😄
@manutter51 it's already like that
@lepistane is your pdf-doc
a string?
What’s making this a bit more complicated than usual is you’re trying to call a command line tool as though it were a java lib
@manutter51 i know that. the thing is when i tried to make regular function it just went over my head with all document types of pdfbox lib
Yeah, there’s no reason you should be able to do that as long as you remember it’s expecting command line arguments
which means pdf-box
should be the name of the file you want to convert, I think
(haven’t done this myself, making educated guesses here)
Sounds like hmaurer was on the right track with to-array
but why is it complaining about getting an object where it expects a string?
What do you get if you print (class pdf-doc)
before the call to ExtractText/main
?
(println (class pdf-doc))
I should say
(defn pdf-to-html [pdf-doc]
(ExtractText/main (into-array String ["-html" "MarkoStankovic.pdf"])))
Interesting
found that function in https://clojuredocs.org/
thx for help @manutter51 @hmaurer 💋
@lepistane ah yeah, that makes perfect sense