Fork me on GitHub
#beginners
<
2015-11-28
>
andymyers08:11:44

So I think it worked, just gave that message. lein repl takes me to a repl at least

roelof12:11:11

@andyshuxin: I use the normal prompt on Windows 10 and everything works well

seancorfield12:11:27

Yeah I just installed lein.bat on Windows 10 and using the regular cmd.exe it works fine (I had to wipe/reinstall my laptop recently).

seancorfield12:11:05

I previously installed it via the packaged installer but went with the plain .bat file this time.

seancorfield12:11:06

FWIW I also have GOW installed (Gnu On Windows). Highly recommended. Lighter weight than Cygwin.

seancorfield12:11:48

(I'm only here briefly -- middle of the night and can't sleep!)

roelof12:11:48

@seancorfield: never heard of GOW , I use only plain windows so some plugins are not working. They need bash

roelof12:11:59

I hope you sleep well later

roelof12:11:12

good night sleep is very important

thedavidmeister13:11:16

i need a bit of a hand with namespaces and protocols in clojurescript

thedavidmeister13:11:57

(ns app.vectors)

(defprotocol IEnsureValue
  "Protocol for data types that can have a value ensured at a position"
  (ensure-last [this v] "Ensure the last item of this is v"))

(extend-type PersistentVector
  IEnsureValue
  (ensure-last [this v] (let [z (last v)]
    (cond
      (not= z l) (conj v l)
      :else v))))

thedavidmeister13:11:47

now in another file, i have

thedavidmeister13:11:07

( app.vectors-test)

thedavidmeister13:11:25

(ns app.vectors-test)

thedavidmeister13:11:48

so I’m not sure how to get (ensure-last …) working

thedavidmeister13:11:13

i tried the things i normally would to require a function and pull it in

thedavidmeister13:11:42

but when i run tests, i get things like "WARNING: Use of undeclared Var"

thedavidmeister13:11:00

i feel like i’m missing something obvious

cjmurphy13:11:09

I've only ever used defrecord. Is there a reason to use extend-type?

thedavidmeister13:11:18

i’ve never done this before

thedavidmeister13:11:37

but i’m trying to extend vanilla vectors

thedavidmeister13:11:42

i thought records were for new data types

adam_cameron13:11:54

@andymyers: I just got the same thing on Windows 10. Seemed to work though

thedavidmeister13:11:29

oh, i got another bug in that code from copying and pasting wrong 😛

binduwavell18:11:20

markmandel, what would go into that docker container? (I ask because I've built some docker containers for new folks to play with clojure in codenvy...)

binduwavell18:11:24

Has anyone worked through the following exercise (or willing to help me having not worked through it) from the concurrency chapter in Clojure for the Brave and True: Create a new function that takes a search term and search engines as arguments, and returns a vector of the URLs from the first page of search results from each search engine

markmandel18:11:49

java, lein, an emacs setup that is ready to go? maybe node in case of clojurescript?

val_waeselynck18:11:14

@binduwavell: making 1 future per search engine, then deref'ing them all at the end to build the map.

binduwavell18:11:21

@val_waeselynck: I have already completed: Write a function that takes a string as an argument and searches for it on Bing and Google using the slurp function. Your function should return the HTML of the first page returned by the search.

binduwavell18:11:29

And then updated that to provide a list of search engines

markmandel18:11:35

Just a thought

binduwavell18:11:52

@val_waeselynck: my implementation uses a promise and a future for each request.

markmandel18:11:07

@binduwavell: Exactly what I was thinking

binduwavell18:11:25

However, what I realized is that both bing and google don't actually return results, they return a bunch of javascript

markmandel18:11:16

Also very nice

binduwavell18:11:49

@val_waeselynck: so part of the challenge is just go figure out how to get search results rather than a bunch of javascript.

binduwavell18:11:35

@val_waeselynck: the second thing is how to extract URLs... I figure I could just use regexes for the second part... I prototyped something in the repl:

(re-seq #"(?i)https?://[^ ]+" "one  two  glumpkins")

binduwavell18:11:53

So mostly I'm not really sure how to get actual search results rather than js

binduwavell18:11:11

And I'm interested if there is a better way with vanilla clojure to extract URLs from HTML than REs.

binduwavell18:11:32

@markmandel: I also plan to setup an image with vim instead of (or as well as) emacs... I played with a basic vim setup the other day and it was WAY faster than emacs/cider...

binduwavell18:11:16

I think there are really two things you miss out on with vim (compared to emacs)... first is sort of obvious, if you're an emacs person, you miss out on emacs simple_smile but second is more important for newbies or vi/m folks... emacs has much better refactoring support... you can do refactoring with vim, but it's all pretty much clever RE tricks.

val_waeselynck18:11:38

@binduwavell: when writing scrapers, I personally use something like jsoup to parse the dom and query on it

val_waeselynck18:11:51

you could also use enlive I hear it's good for scraping

binduwavell18:11:24

@val_waeselynck: cool thanks for the pointers, I'll give those a look

roelof18:11:23

anyone who can give me a hint how I can flatten a seq without using flatten. That one is not allowed

cjmurphy18:11:08

Maybe mapcat identity??

roelof18:11:46

Can be a idea . I know that mapcat also can concate lists

roelof18:11:34

@cjmurphy: thanks for the idea. I was thinking for this one for 2 days and still no good idea

cjmurphy18:11:46

It is not that easy. I did plenty of Scala before so knew about identity and flatmap as they call it in that world.

roelof18:11:10

no, and this is one of the easy problems of 4clojure

cjmurphy18:11:20

It is not easy

cjmurphy18:11:10

Just easy for the people who have been doing functional programming for years.

roelof18:11:19

Then I have to be afraid for the hard and very hard problems of 4clojure

roelof18:11:37

im doing this for some 2 - 3 weeks

roelof18:11:20

@cjmurphy: maybe clojure is not the best beginners language for beginners in fp 😞

cjmurphy18:11:53

Its much better than Scala IMO, for learning fp.

binduwavell18:11:55

@roelof: seems like it would be relatively simple to create a recursive implementation of flatten using into and recusion

roelof18:11:20

I also thought of that

roelof18:11:23

@cjmurphy: I looked also at Scala but I find it a confusion mix between fp and op

val_waeselynck18:11:21

@roelof (apply concat seqs)

cjmurphy18:11:51

That's right - implicits and the cake pattern and variations of it and how slow it is with using Option all the time, and then not so many opportunities to 'close over'...

roelof18:11:30

I also tried Haskell but missed there a good book for beginners

roelof18:11:58

So I hope one day clojure clicks for me and I can make web apps in the future

cjmurphy18:11:00

But the worst thing about Scala was SBT - too much wasted time there...

roelof18:11:40

@cjmurphy: so lein is much better then SBT

val_waeselynck18:11:00

@cjmurphy: yeah, they should have called it 'irony', not SBT simple_smile

cjmurphy18:11:58

I saw a video by the creators of SBT and they said 'we won't help you with your build problems'.

cjmurphy18:11:18

And there are so many unanswered SBT questions on SO.

roelof18:11:22

oke, my plan is to do first do the easy exercises of 4clojure and then make the transition to the brave book

roelof18:11:51

and then look for a good book about web development

val_waeselynck18:11:13

@roelof: I really like "Web development with Clojure"

roelof18:11:02

@val_waeselynck: Does that one uses a framework

roelof18:11:43

@cjmurphy: im now with challenge 28 and the last "easy" on has the number 153 so a lot to do

val_waeselynck18:11:06

just a composition of library

roelof18:11:44

oke, I wil take a look at it. Thanks for the tip

roelof19:11:24

@val_waeselynck: I saw that it uses Lighttable a lot. I hope I can make it work with Cursive and Intelij also

val_waeselynck19:11:59

yes of course it's completely orthogonal

val_waeselynck19:11:37

I actually went through all of the book with counterclockwise personally, and am now using cursive

roelof19:11:51

oke, so cursive is "better" then counterclockwise. I tried Lighttable and Cursive so far

roelof19:11:58

and I liked Cursive the most

roelof19:11:15

oke, thanks again

nando19:11:36

@roelof : I tried to work through the flatten exercise last night and found it quite difficult. I'm deciding not to worry about the “easy” designation and rather focus on the fact that the koans are helping me to dig through Clojure’s functions, and maybe even how to think through solving problems using Clojure.

binduwavell19:11:15

@roelof flatten is implemented using tree-seq I guess you could do the same...

roelof20:11:08

@nando thanks for the feedback

roelof20:11:05

I will try some ways and look what works the best

markmandel23:11:13

@nando: still stuck on flatten?

seancorfield23:11:30

@markmandel: my first two "simple and obvious" attempts were simple and obviously wrong so I still need to come up with more ideas simple_smile

markmandel23:11:54

I have an idea .. mebbe it works, mebbe it doesn't