Fork me on GitHub
#clojure
<
2016-12-09
>
bcbradley00:12:59

I'm considering making a library for clojure that is used to generate spir-v code for targeting vulkan enabled gpus

bcbradley00:12:07

spir-v is a binary specification

bcbradley00:12:27

does anyone know of a simple library for generating binary data?

gfredericks00:12:30

like byte arrays?

gfredericks00:12:18

what sort of functionality are you looking for? generic sugary erlang syntax?

bcbradley00:12:08

i've done some byte fiddling in the past and i shot myself in the foot with big endian / little endian byte order and i just don't want to fool around with that part of it if i can avoid it

gfredericks00:12:46

your output format is a file?

gfredericks00:12:07

I can't imagine not needing to know about byte ordering

gfredericks00:12:23

in any language

gfredericks00:12:38

just because I imagine that's a fundamental aspect of the spec

gfredericks00:12:57

it's like wanting to use json without having to worry about how the keys are spelled

gfredericks00:12:16

I just googled "clojure erlang binary syntax sugar" and most of the results are about elixir

bcbradley00:12:46

i guess its not a big deal

bcbradley00:12:52

its just something i have to get right

gfredericks00:12:03

it would be a fun macro exercise to do something equivalent to erlang's syntax

gfredericks00:12:17

maybe one of the libraries already does that

Alex Miller (Clojure team)00:12:22

Gloss is based on the errand stuff I think

bcbradley00:12:11

gloss looks pretty good

bcbradley00:12:15

looks like what i had in mind

royalaid01:12:18

Hey all, looks like with the new predicates in clojure 1.9 core.match spits out WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.tools.analyzer.utils, being replaced by: #'clojure.tools.analyzer.utils/boolean? when included

royalaid01:12:54

Is there any way I can work around this? trying to make a command line application that returns json and this gets printed everytime preventing me from piping to jq

hiredman01:12:24

move to a newer tools.analyzer

hiredman01:12:52

stick a grep -V WARNING in there

bbloom01:12:20

is every-kv supposed to work on vectors?

bbloom01:12:32

user=> (s/conform (s/every-kv integer? string?) ["x"]) :clojure.spec/invalid

bbloom01:12:40

it would be awesome if it did 🙂

bbloom01:12:53

it seems to work for empty vectors:

bbloom01:12:53

user=> (s/conform (s/every-kv integer? string?) []) []

bbloom01:12:24

filed CLJ-2080

Alex Miller (Clojure team)02:12:39

What does explain tell you?

bbloom02:12:04

user=> (s/explain (s/every-kv integer? string?) ["x"]) In: [\x] val: "x" fails predicate: vector? nil

Alex Miller (Clojure team)02:12:53

Looks like it's expecting vector entries

Alex Miller (Clojure team)02:12:22

I'm not honestly sure of the intention

bbloom02:12:47

based on the doc string, i expected it to treat the vector like an associative collection

bbloom02:12:55

eg a map with integer keys

bbloom02:12:04

anyway, sorry to dump a problem and run, but dinner time!

fenton04:12:30

how to predefine a function so you can use in file before it is read?

fenton04:12:51

got it declare

leov06:12:00

are there plans to have vector namespace syntax similar to map namespace syntax - to better support datomic pull syntax, specifically attributes list in query?

johnnyillinois08:12:03

Anyone know why ring is not setting cookies on response?

(-> (ok "Hello")
        (assoc-in [:cookies "X-WEB-AUTH-USER"] {:value "Thing", :max-age 3600})
         trace)
Produces:
{:status 200, :headers {}, :body "Hello", :cookies {"X-WEB-AUTH-USER" {:value "HALO", :max-age 3600}}}

chrisetheridge08:12:38

which ns does ok come from @johnnyillinois

chrisetheridge08:12:12

(require '[ring.util.response :as res])

  (-> (res/response "hello")
      (assoc-in [:cookies "X-WEB-AUTH-USER"] {:value "Thing", :max-age 3600}))

>> {:status 200, :headers {}, :body "hello", :cookies {"X-WEB-AUTH-USER" {:value "Thing", :max-age 3600}}}

chrisetheridge08:12:14

works fine for me

henriklundahl08:12:28

@johnnyillinois Make sure you use the ring.middleware.cookies/wrap-cookies middleware.

henriklundahl09:12:04

You can also use ring.util.response/set-cookie instead of assoc-in ....

mak10:12:51

I want to get inputs from user into a list

mak10:12:08

and use that to pass it to a function

mak10:12:21

I have written like the following

mak10:12:44

(defn mylist[] (map parse-int (repeatedly tc read-line)))

mak10:12:00

and passed to function myfunction like this

mak10:12:09

(map myfunction mylist)

mak10:12:30

but myfunction is called

mak10:12:38

for each input from the user

mak10:12:50

instead I want to get all the input from the user

mak10:12:58

and then pass it to the function

mak10:12:08

sorry, if it is not clear

mak10:12:24

please ask me any input if required

val_waeselynck10:12:24

@mak can't you just call (myfunction mylist) ?

mak10:12:34

my requiement is something like this, I want to take input from the user and pass each number to the list and confirm , if it is odd or even

mak10:12:41

i have written to print the even or odd

mak10:12:00

now I am reading the list from the user for let us say for 3 inputs

mak10:12:35

once I take the all the 3 inputs from the user then only I want to pass that list to myfunction

mak10:12:57

currently, for each user input 'myfunction' is called

mak10:12:38

myfunction takes only one parameter

mak10:12:04

so I think , we need to call like (map myfunction mylist) only

mak10:12:21

as this will take each parameter from the list and applies the function

mak10:12:27

correct me, if I am wrong

val_waeselynck11:12:52

@mak: what you mean is that you need to realize the full list before applying myfunction to each element, correct ?

val_waeselynck11:12:34

in this case, you can use doall, e.g (map myfunction (doall (my-list)))

val_waeselynck11:12:50

btw, if you're running myfunction for side effects (e.g printing to the screen), it's preferable to use run! instead of map: (run! myfunction (doall (my-list)))

mak11:12:32

Wow! Thanks a lot @val_waeselynck

mak11:12:46

that is exactly my requirement

mak11:12:09

Now, I have an additional query

mak11:12:30

while printing the output, I am getting

mak11:12:45

(nil nil nil)

mak11:12:50

for each println

mak11:12:59

now how can I avoid printing it

val_waeselynck11:12:50

It's not printing it, its the return value

val_waeselynck11:12:02

There has to be one.

val_waeselynck11:12:41

It does not affect the execution of your program outside of the repl

mak11:12:13

Thanks again @val_waeselynck. It's a great help to me.

dottedmag13:12:30

I was reading Rich's interview about spec and have found the following snippet: "But, yes, I'd like to see more namespaced keys. We're adding a little bit of syntax to Clojure to make that even easier, literally just easier so that people do more of it." -- what does he refer to?

ambrosebs13:12:44

and destructure has been extended for namespaced keyword entries

neil.clarke13:12:03

hey there - is there any way to use transducers without the reducing function? I have a composed set of filters, and I just want the filtered records; not reduced to a value...

neil.clarke13:12:06

@alexmiller Thanks! I just spotted that... Appreciate it

roelofw14:12:39

Can I test some functions that are depend on reponses of a external api and if so, can someone share some examples how I can make such a test

mpenet14:12:24

you mean with spec?

roelofw14:12:14

Does spec work on 1.8. I thought spec only works on 1.9 ?

mpenet14:12:39

there's spec as a lib somewhere on github

mpenet14:12:07

but if you have trouble creating a simple test for this, maybe don't dive in generators just yet

roelofw14:12:45

@mpenet thanks, I think I will read a lot about specs

roelofw14:12:22

I hope I can find out how to mock the api server because I think test schould never use the real api

mpenet14:12:33

yep, sounds like the way to go

roelofw14:12:24

so I can validate a json response and test if the outcome of the parsing will be what I expect. ?

roelofw14:12:41

I can not find any examples of this with google 😞

jcromartie14:12:27

TIL about run!

jcromartie14:12:28

"Today I Learned" @val_waeselynck mentioned it in a discussion about doall etc. above

jcromartie14:12:49

I have been using doall and map forever, and didn't know about the addition of run! to clojure.core

roelofw14:12:12

oke, I thought that was a answer to my question

jcromartie14:12:17

@roelofw I see a lot of questions up there 🙂

jcromartie14:12:29

you want to mock an external service for tests?

jcromartie14:12:46

what part are you stuck on?

roelofw14:12:57

How to do it

roelofw14:12:29

I have read a lot about spec and other test frameworks but I never see a example of this

jcromartie14:12:34

the simplest way is probably using with-redefs

jcromartie14:12:01

you just redefine the function that calls the external service with a mock version

jcromartie14:12:06

for the scope of your tests

jcromartie14:12:29

keeping in mind that with-redefs is not thread safe and updates the root binding of vars

jcromartie14:12:36

but it's fine for tests

tankthinks14:12:10

@roelofw you can also use something like http://www.mbtest.org/, it’s language agnostic and allows you to stand up mock http/https/smpt/tcp servers

roelofw14:12:44

oke, so I run the external api like this :

(client/get  "" {:as :json :query-params {:key (env :key) :format "json" :type "schilderij   

roelofw14:12:20

How do I redefine this ?

roelofw14:12:38

by making a variable with some json in it ?

jcromartie14:12:39

that get call should be inside a function

jcromartie14:12:49

i.e. you've got a function somewhere that calls this API, yes?

jcromartie14:12:03

so if it's (defn foo [] (client/get ...))

roelofw14:12:05

yes. I showed you that

jcromartie14:12:00

you showed me the detailed code that calls the API, so I don't assume you have it in a discrete function

jcromartie14:12:09

so in your tests you'd use (with-redefs [paintings2.api-get/read-numbers (constantly [1 2 3...])] your-test-code)

jcromartie14:12:31

substituting whatever expected return value you want

roelofw14:12:59

oke, so 1 2 3 is the output of the external api ?

jcromartie14:12:06

yeah, just as an example

roelofw14:12:17

oke, then I see it

jcromartie14:12:19

(constantly x) creates a function that just returns x

jcromartie14:12:35

so you're substituting your functions that call the API with functions that just return test values

jcromartie14:12:58

and if you need more state than that you can use an atom or something and make your redef functions more complicated

roelofw14:12:02

oke, now choosing what for test-framework I m going to use

jcromartie14:12:07

clojure.test

roelofw14:12:21

oke, so no spec ? or midje ?

jcromartie14:12:34

midge is nice

jcromartie14:12:48

but if you don't know clojure.test then you should at least get familiar with it

roelofw14:12:10

oke, next thing on my learning path

jcromartie14:12:43

if you ever wonder "which x should I use", and a core library is one of the options, learn the core library first

roelofw14:12:46

nice to experiment with it the next few days/weeks

jcromartie14:12:25

knowing clojure.test means you can contribute to most open source Clojure libs, and using it in your own lib means most devs can contribute to yours

roelofw15:12:01

yep, that is why 4clojure challenges is a lot about solving with only core functions

roelofw15:12:33

This is a personal project. I do not thing many other clojure devs are joining my project

roelofw15:12:15

time for a very very late lunch. In 2 hours I can eat the evening dinner 🙂

roelofw15:12:27

@jcromartie thanks for the help

roelofw15:12:15

chips, something not right here :

(ns paintings2.test.get-api
  (:require [clojure.test :refer :all]
            [ring.mock.request :refer :all]
            [paintings2.api-get :refer :all]))

(deftest test-app
  (testing "get numbers"
    (let [response (with-redefs [paintings2.api-get/read-numbers (constantly [{:id "1234"} {:id "abcd"} ])])
          (is (= [ "1234" "abcd"] (map (get-in response [:body :artObjects] ) response)))]))) 

roelofw15:12:40

I see this error message : let requires an even number of forms in binding vector in paintings2.test.get-api:8

dpsutton15:12:29

look at how to use redefs

dpsutton15:12:48

also, i'm not sure you're testing anything here

val_waeselynck15:12:03

@roelofw that's just a 'syntax' error, you misplaced the closing bracket of your let

dpsutton15:12:05

you're just looking at the object that your redefined function returned, rather than looking at the logic you have coded

jcromartie15:12:52

there are a few issues here

jcromartie15:12:54

let's slow down

roelofw15:12:16

I try to test if the code can take the id of a json response which a external api has returned and is parsed by the get

roelofw15:12:25

jcromartie oke, I slow down

jcromartie15:12:31

first: with-redefs redefines a var only within the scope of with-redefs itself, so since there's nothing in the body of with-redefs your mock function is never called.

jcromartie15:12:11

You need to put your test code that calls the redefined functions inside the body of with-redefs

jcromartie15:12:30

second: it looks like you're expecting your function to return something much different from what you're returning using constantly

jcromartie15:12:36

what is :body and :artObjects ?

jcromartie15:12:14

forget about the API call for a moment and just focus on mocking your functions

roelofw15:12:32

:body and :artobject are keys in the parsed response of the external api

roelofw15:12:08

the external api sends a big json response and I only need a small part of it

jcromartie15:12:53

so, it looks like your function read-numbers returns values parsed from that response

jcromartie15:12:57

not the response itself

jcromartie15:12:18

so when you mock read-numbers, you are just skipping the API call entirely and returning what you expect read-numbers to return

roelofw15:12:54

oke, that will be something like [ "123" "456" ]

dpsutton15:12:38

and roelofw, which function do you want to test here?

roelofw15:12:18

where the response could look like this : [ { :id 123 :painter "me"} { :id 345 :painter "you}]

roelofw15:12:30

the read-numbers function first

dpsutton15:12:40

but you are mocking read-numbers, how could you test it

dpsutton15:12:43

you aren't even calling it

roelofw15:12:44

@dpsutton oke , back to the clojure.test manual

dpsutton15:12:56

you don't need to read the manual

dpsutton15:12:00

what function do you want to test

dpsutton15:12:04

that's step 1

jcromartie15:12:04

if you want to test your response parsing, then mock client/get and returns the response you expect

roelofw15:12:30

oke, that is what I tried to do

martinklepsch15:12:37

Is there a nil-safe implementation of Clojure maps? Like one that throws with (get {} :a)

mpenet15:12:23

(get m :foo ::not-found)

jcromartie15:12:48

the existing implementation is what I'd call "nil safe"

roelofw15:12:48

I can mock it up with : (with-redefs [paintings2.api-get/read-numbers (constantly [{:id "1234"} I think

roelofw15:12:24

Sorry I do not mock it up like this

jcromartie15:12:39

the most important question is: what are you trying to test?

dpsutton15:12:00

yeah. which function are you trying to test

dpsutton15:12:09

post the body of the function you are trying to test here

dpsutton15:12:20

let's see what its dependencies are

roelofw15:12:24

if read-numbers parse the json right and I see a map of only the objectNumbers

mpenet15:12:28

there's also the barely readable (:foo {} ::not-found)

dpsutton15:12:34

post that function here

roelofw15:12:51

so this part :

(defn read-numbers
  "Reads the ids of the paintings"
  []
  (->> (client/get  "" {:as :json :query-params {:key (env :key) :format "json" :type "schilderij" :toppieces "True"}})
                 :body
                 :artObjects
                 (map :objectNumber))) 

dpsutton15:12:05

and remember, redefs is making a fake implementation of a function. so we cannot possibly fake the function we want to test

jcromartie15:12:07

so you want to verify that the logic within read-numbers is correct?

dpsutton15:12:21

awesome. now we are onto something

jcromartie15:12:32

@dpsutton that was my example, initially, because I thought he wanted to test code that used read-numbers

dpsutton15:12:45

i was thinking the same thing

martinklepsch15:12:46

@mpenet @jcromartie sorry probably messing up terminlogy. I want a thing that throws when theres no value for a given key

dpsutton15:12:53

that was the value of saying exactly which function we want to test

roelofw15:12:03

so we have to mock the client-get line up with with-redefs

dpsutton15:12:17

we are mocking the dependencies of the function we want to get

dpsutton15:12:25

now, here's another suggestion

mpenet15:12:27

@martinklepsch just add a (when (= ::not-found ...) (throw ...)) and you get that

dpsutton15:12:29

we might want to refactor

dpsutton15:12:39

maybe we want to call read-numbers on the result of the client get

jcromartie15:12:41

@martinklepsch no, clojure's associative data structure functions are rather forgiving

mpenet15:12:46

@martinklepsch alternatively contains?

dpsutton15:12:47

and that way read-numbers is pure

dpsutton15:12:53

and then we don't have to mock anything at all

roelofw15:12:21

oke, so we make a sort of fake respons , @dpsutton

dpsutton15:12:39

then the call site would look like (read-numbers (client/get url options))

dpsutton15:12:45

and that way options and url are just vars

dpsutton15:12:04

well, we just call that function on different data and see what we get

roelofw15:12:11

oke, so first refractor the "real" read-numbers ?

martinklepsch15:12:22

@mpenet all this requires an extra fn/some wrapping. I want something that exposes the same interface as regular maps but throws in said case

jcromartie15:12:00

@martinklepsch you'll just have to write it

martinklepsch15:12:33

@jcromartie haha thanks, the reason I asked is because maybe anyone knows of somebody else who already did 😄

roelofw15:12:46

@dpsutton : Schould I rewrite the read-numbers function ?

dpsutton15:12:55

just refactor, not rewrite

mpenet15:12:56

@martinklepsch yup, or use something like potemkin and define your own map type (here be dragons)

roelofw15:12:24

oke, I have to think then how I can do that

dpsutton15:12:31

pull the client/get out and just assume you have the response as the parameter

dpsutton15:12:40

its just the first part of your threading macro

dpsutton15:12:48

just move that to the call site of read-numbers

dpsutton15:12:49

and you are done

roelofw15:12:33

oke, the call site is here :

(defn do-both-in-parallel [ids]
  (let [paint-thread (future (pmap read-data-painting ids))
        image-thread (future (pmap read-image-url ids))]
    (map merge @paint-thread @image-thread)))  

martinklepsch15:12:42

@mpenet ah neat, def-map-type seems handy didn't know potemkin has stuff like this

roelofw15:12:12

and that calls this one :

(defn read-data-painting
  "Reads the title, description, date , collection, colors and url of a image"
  [id]
  (let [art-objects (-> (str "" id )
                        (client/get {:as :json :query-params {:key (env :key) :format "json" :type "schilderij" :toppieces "True"}})
                        :body
                        :artObject)
        name        (-> art-objects
                        :principalMakers
                        first
                        :name)
        description (:description art-objects)
        date (get-in art-objects [:dating :year])
        collectie (first (:objectCollection art-objects))
        colors (:colors art-objects)]
    {:id id :name name :description description :date date :collectie collectie :colors colors}))

roelofw15:12:31

so I have to refractor a lot of functions then

roelofw15:12:05

because this one is also using client/get which also can be refractor to get this out

jcromartie15:12:15

I was afraid we might just be kicking the can down the road

dpsutton15:12:16

you don't have to refactor out every client get

dpsutton15:12:23

the read-data-painting is great

dpsutton15:12:28

it doesn't do very much work

dpsutton15:12:33

it just destructures the json more or less

dpsutton15:12:40

that's a great place to have a client/get inside of it

roelofw15:12:04

it reads the numbers and do a client-get to get a new response to get more data of that painting

dpsutton15:12:05

its very much take an id and then return the response in a format that we want

dpsutton15:12:21

its logically self contained

roelofw15:12:30

oke, but can I test this function later on then ?

dpsutton15:12:31

i take an id and i return the json data in a format that you like

dpsutton15:12:33

i like that function

dpsutton15:12:52

let's leave that off for now

roelofw15:12:05

I have another function that do the same to get the image out of of 1 painting

scott.haleen15:12:13

Is there a higher order function or idiomatic way to convert a sequence of maps to a map based on a key fn? Or is it just reduce ex. (reduce #(assoc %1 (:id %2) %2) {} [{:id 1} {:id 2}]) ;;=> {1 {:id 1}, 2 {:id 2}}

dpsutton15:12:55

so where is read-numbers called?

dpsutton15:12:59

that's the function we want to test

roelofw15:12:01

@dpsutton im still missing you, the last function takes the output of read-numbers

roelofw15:12:26

here , (map merge @paint-thread @image-thread)))

dpsutton15:12:42

i don't see a call to read-numbers

roelofw16:12:31

Wait , I see what you mean

dpsutton16:12:33

if we pull the client/get out of read-numbers, where is the call site(s) that we would need to update

dpsutton16:12:01

it drifted far away, but this is the code we want to test

dpsutton16:12:32

show me the code that calls this function

roelofw16:12:54

that is here :

ns paintings2.routes.home
  (:require [paintings2.layout :as layout]
            [compojure.core :refer [defroutes GET  ]]
            [ring.util.http-response :as response]
            [ :as io]
            [paintings2.api-get :as api]
            [compojure.route :refer [resources]]))

(defn home-page []
  (layout/render
    "home.html" {:paintings (api/do-both-in-parallel(api/read-numbers))  }))

(defroutes home-routes
  (GET "/" [] (home-page))
  (resources "/")  )  

roelofw16:12:22

in the file routes/home.clj

dpsutton16:12:24

ok. so if we pull it out, we can make it look like this

dpsutton16:12:45

or even move the paintings threading macro into the let bindings

dpsutton16:12:58

let's get the data, and then throw that through out pipeline

roelofw16:12:08

yep, I think slack messed up your indentation

roelofw16:12:21

but I see now the idea

dpsutton16:12:34

make read-numbers take data and return data

dpsutton16:12:45

and then call read-numbers with that data

roelofw16:12:09

and then I can test it with dummy data that I can make up, right ?

dpsutton16:12:40

then you don't redefine anything

dpsutton16:12:52

you just call your function with whatever data and make sure it spits out what you expect

seancorfield16:12:01

@roelofw I can’t help but feel this really still belongs in #beginners ...

roelofw16:12:20

and I can do the same with the other two functions

roelofw16:12:44

oke, I will ask questions in the beginnners channel , I apolize

seancorfield16:12:55

Thanks. Happy to help you in that channel.

roelofw16:12:12

i have one question which I will ask in the beginners channel

camdez16:12:13

@jrheard: what do you think about bifurcate as a name for the function formerly known as winnow?

camdez16:12:41

@jcromartie Thanks for the feedback!

jrheard16:12:37

totally works, yeah

camdez17:12:30

@jrheard: I’m trying to decide if it carries a hint of “two even parts”, but I don’t think it does. “Bisect” is also an option, but seems (to me) to have more of that “equal” implication.

camdez17:12:32

Idk, maybe bisect is better, looking at roots. Naming. Eek.

camdez17:12:38

"In geometry, bisection is the division of something into two equal or congruent parts.” (WP) Back to bifurcate. 🙂

tankthinks19:12:52

I’m trying to convert a Rubyist colleague to Clojure … I’ve tried the obvious points but I may need to admit defeat ... some people just want resources

donaldball19:12:57

Different strokes for different folks, but the best part about clojure v. ruby for me: in clojure, I can look at a fn call and know, by and large, exactly what is going to happen. In ruby, with all the mixins and patching monkeys? You really can’t know; you have to actually call it and see what happens (and hope all the effects are visible).

tankthinks19:12:33

thanks @donaldball … I tried a similar tact … having built a concurrent program from ground up (not just use a web framework) before helps too

tankthinks19:12:55

at my last gig, we built a distributed file system cache in Java ...

tankthinks19:12:16

… so … yeah … been there done that

camdez20:12:12

@tankthinks What do you mean by resources?

ddeaguiar20:12:36

thinking that's orthogonal

camdez20:12:08

@tankthinks have you looked at things like yada?

ddeaguiar20:12:47

There are libs that provide such an abstraction for web dev. Consider Liberator.

ddeaguiar20:12:21

oh never looked into yada

tankthinks20:12:22

i had not looked into liberator or yada

tankthinks20:12:45

I was simply using compojure and compojure-api

camdez20:12:34

I think you can get a lot of the convenience of Rails’ resources with better HTTP compliance and all defined with data rather than a DSL.

tankthinks20:12:04

but you’re probably right @camdez and @ddeaguiar … i think these are surface excuses for an underlying “don’t get the whole functional programming paradigm"

tankthinks20:12:38

I just didn’ have quick answers to … yeah we’ve got an analog to your magic framework

camdez20:12:01

We’ve got comprehensible magic. 🙂

ddeaguiar20:12:47

Not sure how close some of the existing web dev libs come to rails but in my experience, explicitness is preferred over magic

tankthinks20:12:12

that was my point exactly … i come from a deep java background … with too much spring magic

tankthinks20:12:32

i don’t want magic … i want to know what the f is going on

ddeaguiar20:12:04

fwiw, Luke Vanderhart is working on Arachne. It's going to be a framework for building apps with initial focus on web apps.

ddeaguiar20:12:21

There's a channel for it if interested #arachne

tankthinks20:12:48

yup … i’ve read the #arachne blog p

ddeaguiar20:12:49

But the general clojure dev experience is composing libs to build what you want

oli21:12:29

hi - how do i feed the results of one pass of map to the next if mapping over a vector of vectors?

gfredericks21:12:09

(map #(map (comp f1 f2) %) vec-of-vecs) maybe?

oli21:12:12

hmmm. turned out my code worked already - now i can't figure out why...

lvh21:12:11

that feels like it’s begging for reductions if you want the intermediate steps and reduce if you don’t.

oli22:12:27

i am a bear of little brain...

camdez22:12:15

Yeah, reduce sounds right here but I’m not totally sure what the goal is...

mnespor22:12:59

It's a little spoiler-y but you might enjoy the conversation in #adventofcode

camdez22:12:55

@mnespor: now I get what we’re doing here. 🙂 http://adventofcode.com/2016/day/2

camdez22:12:15

@oli: regarding your comment, there’s no overlap between the processing of each digit in the final code. Running your code, I get 1945, not 1985, which I believe is expected.

camdez22:12:24

Yep. Verified. Let me know how much of a hint you’re looking for. haha.

oli22:12:36

you're right. the (extremely long) inputs in the 'real' problem set just happen to eval to the right answer... 😛

oli22:12:45

which brings me back to how to i pass the result of processing one list in my list-of-lists to the next list to be processed...

camdez22:12:47

@oli: I’ll say this, to avoid spoiling it: map won’t allow you to retain any information from the previous digit, which is essential. You could use reduce, and reach back into the accumulated list of digits every time (I just implemented this). But the cleanest solution is likely going to be to use loop / recur.

camdez22:12:37

One of your bindings in loop is going to be the previously calculated digit (or position).

oli22:12:32

that's enough to go on, thanks!

camdez22:12:16

@oli: you’re very welcome. Best of luck!

camdez22:12:18

@oli: another small hint: I don’t think you’re gonna end up using that two-arity version of process-instructions.