Fork me on GitHub
#beginners
<
2015-12-12
>
conner00:12:31

just started clojure recently as a javascripter, read this just now and it helped heavily: https://yogthos.github.io/ClojureDistilled.html

conner00:12:38

might be good for others in here with a similar background

Tim00:12:38

clojure distilled is surprisingly dense and useful

Tim00:12:48

I’m still finding things in it that I find good

Tim00:12:56

after about six months or so after reading

firinne02:12:15

Has anyone found and good resources on deploying an app with Datomic, I’ve been teaching myself to use Docker this past week, trying make all the pieces fit together, dealing with a lot of dev-ops stuff I’d never encountered before. Starting to wonder if I would have been better off sticking with heroku. Anyone recently deploy for first time? https://github.com/opengrail/heroku-buildpack-datomic

roelof09:12:18

Can anyone help me find out how I can make this work so I can calculate things like 2 ^ 3

roelof09:12:35

my code so far is this :

(defn test-recursion
  [ x y]
  (reduce (fn [acc ]  (* acc )) x (range 1 (+ y 1)))
)

roelof09:12:00

somehow I have to use the x in the anymous function

roelof09:12:48

oke, so I can also so reduce * (repeat x y) where x is 2 and y = 4 as a example ?

roelof09:12:39

I have solved the whole problem now

bloemelau15:12:08

Hello everyone!

bloemelau15:12:44

Does anyone know where i can find the api of incanter? The normal site at http://liebke.github.io/incanter is 404ing for me...

bloemelau15:12:31

Thanks, @alexmiller ! I guess the links on the readme in github and ond their site need to be replaced.

alexmiller15:12:56

yeah, looks like it was moved

roelof16:12:17

A maybe stupid beginners question . Lets say I have the number 81 and I want to place it into a list like this ( 8 1)

roelof16:12:35

Is recursion then the best option to do ?

mccraigmccraig16:12:30

@roelof you could also map over a seq of powers of 10, div yr number by 'em then take-while >0 and reverse

roelof16:12:40

oke, but then if a number is bigger then the greatest power the answer will not be right

roelof16:12:36

I try to understand how I can solve this problem : http://www.4clojure.com/problem/99

bloemelau16:12:04

@roelof: To add to your comment on having a problem with the biggest value: Clojure will promote to BigInteger, so no problems

bloemelau16:12:30

That is if one of the arguments passed is a BigInteger already, for example: (type (+ Long/MAX_VALUE 1)) ;=> overflow but (type (+ Long/MAX_VALUE 1N)) ;;=> clojure.lang.BigInt

roelof17:12:27

oke, that can also be a solution

roelof17:12:33

@bloemelau: Character/getNumericValue is java ?

roelof18:12:30

Is there also a pure clojure solution ?

roelof18:12:11

I thought this could be a answer (reduce (fn[acc it] (conj acc it)) () [(str(128))] )

mccraigmccraig18:12:16

@roelof (iterate #(* 10 %) 1) is an infinite sequence of powers of 10 - you can use that

roelof18:12:20

but error messages

roelof18:12:06

@mccraigmccraig: oke, I have to think how that can work for me

roelof18:12:19

I will do that tomorrow , My head is spinning

mccraigmccraig18:12:57

lazy seq transformation can do that to a head 🙂🙃🙂🙃🙂

rantingbob18:12:21

Is there a good blog or site with some examples of using clojure.test?

agile_geek18:12:25

Just more proof that (not= "simple" "easy")

rantingbob18:12:19

Oh...how did you do that?

agile_geek18:12:53

Clojurebot - you can submit Clojure expression prefaced by /clj

rantingbob18:12:21

Cool...thanks

roelof18:12:59

someone who can help me with a pure clojure function to split a number into digits ?

agile_geek18:12:30

@rantingbob: There are lots of examples in Clojure github repo's. Have a look at this too http://blog.jayfields.com/2010/08/clojuretest-introduction.html

roelof18:12:13

I tried something like this (reduce (fn[acc it] (conj acc it)) () [(str(128))] ) but that does not work

mccraigmccraig19:12:01

@roelof

(defn digs [n]
  (->> (iterate #(* 10 %) 1)
       (map (fn [p]
              (when (<= p n)
                (quot
                 (- n (* (* p 10) (quot n (* p 10))))
                 p))))
       (take-while identity)
       reverse))

mccraigmccraig19:12:27

and in any base (<=10) simple_smile

(defn digs
  ([n] (digs n 10))
  ([n b]
   (->> (iterate #(* b %) 1)
        (map (fn [p]
               (when (<= p n)
                 (quot
                  (- n (* (* p b) (quot n (* p b))))
                  p))))
        (take-while identity)
        reverse)))

mccraigmccraig19:12:33

much neater :

(defn digs
  ([n] (digs n 10))
  ([n b]
   (->> n
        (iterate #(quot % b))
        (map #(when (> % 0) (mod % b)))
        (take-while identity)
        reverse)))

Tim23:12:52

how can I get this test to pass to pass

(deftest tagged-test
  (is (= true (l/tagged-list? (quote ((quote define) 32)) (quote define)))))
where tagged-list? is
(defn tagged-list?
  [exp tag]
       (= (first exp) tag))

Tim23:12:19

or maybe this test makes it clearer:

(deftest tagged-test
  (is (= true (l/tagged-list? '('define 32) 'define))))

Tim23:12:22

this test passes on the contrary:

(deftest tagged-test
  (is (= true (l/tagged-list? ['define 32] 'define))))
but I’d like to use lists instead of vectors

solicode23:12:45

It's because those aren't the same. You have an extra quote in there. Instead of '('define 32), try using '(define 32)

solicode23:12:28

@tmtwd: Also, this is small, but the = true isn't necessary. You can shorten it to:

(deftest tagged-test
  (is (l/tagged-list? '(define 32) 'define)))

Tim23:12:14

but I want to pass in a list whose first arg is ’define

Tim23:12:53

hm, this works

(deftest tagged-test
  (is (= true (l/tagged-list? ['define 32] 'define))
      (l/tagged-list? (list 'define 43) 'define)))

Tim23:12:38

hm, I guess there is no shorthand for list …..

Tim23:12:52

it appears they are equal at first but I guess they do very different things:

lisp-interpreter.server=> (= (list 1 2 3) '(1 2 3))
true

Tim23:12:24

I guess I’ll just use list for stuff like this then

solicode23:12:32

Right, those are equal. Using a quote for that instead of list is perfectly okay, and very common.

solicode23:12:53

@tmtwd: But just in case, what I'm trying to say is that these are the same:

(= (list 'define 32)
   '(define 32))

solicode23:12:05

If you understand that, I think this will start making sense.

Tim23:12:09

oh I see

Tim23:12:12

interesting

Tim23:12:15

thank you

solicode23:12:56

You can’t do (list define 32) though.

Tim23:12:06

nice that works too