Fork me on GitHub
#beginners
<
2015-12-10
>
roelof06:12:58

oke, so like this : ) part ) (map #(str %1 "-") (range 1 n)))))

roelof06:12:28

hmm, not working

roelof06:12:52

I hope today someone can help me to get it right

naomarik07:12:06

@roelof: can you post the full code you're evaling in refheap?

roelof07:12:25

yes. this is the code I have so far : https://www.refheap.com/112536

naomarik07:12:24

what's the def for asym-hobbit-body-parts

roelof07:12:04

sorry I forget . Here a better paste : https://www.refheap.com/112537

roelof07:12:53

@naomarik: I hope this is enough info

naomarik07:12:40

@roelof: you wanted output like

[{:name "head1", :size 3}
 {:name "head2", :size 3}
 {:name "head", :size 3}
 {:name "left-eye", :size 1}
 {:name "eye2", :size 1}
right?

roelof07:12:16

I wanted to see this output

roelof07:12:00

` [{:name "head", :size 3} {:name "eye1", :size 1} {:name "eye2", :size 1} `

naomarik07:12:35

so eye1 and eye2, the numbers are based on the parameter you passed here? (symmetrize-body-parts2 asym-hobbit-body-parts 2)

roelof07:12:53

so only for the parts that starts with left I wanted to change it to part-number without the left

naomarik07:12:32

part-number is the size +1?

roelof07:12:32

Yep, thats why I have used range so range 1- 4 gives eye1 , eye2, eye3

roelof07:12:26

part-number is the number which comes out of the range function. it needs to stop on n + 1 because otherwise I get one part less

roelof07:12:50

or do we misunderstood each other ?

roelof07:12:02

@naomarik: still here or given up ?

naomarik07:12:28

trying to find out how to do certain things

naomarik07:12:19

@roelof: not sure i'll have time to finish it but the gist of what i might do is (str (clojure.string/replace (:name part) #"^left-" replacement)) in here i would use a capture group to perform the replacement at the end of the string. i'm not sure how to do this in clojure but you'd look into capture groups. and then to get rid of the "left" thing completely from the array i would apply a filter to the output

roelof07:12:11

oke, thanks for the tip

naomarik07:12:55

i'll get back to you if i figure out the capture group thing, kind of important thing for me to know as wlel 😛

roelof08:12:41

no problem. This problem has no rush. IM trying to learn clojure as a hobby so no dead lines

roelof08:12:49

Thanks for the help so far

naomarik08:12:19

(clojure.string/replace (:name part) #"^left-(.*)" #(str (last %1) replacement)) this would give you the replacement at end of the part

naomarik08:12:43

from there you just need to remove the "-" in your range function then use a filter to remove the "left" parts simple_smile

roelof08:12:29

thanks, that looked almost as I wanted to look

naomarik08:12:45

(fn [{name :name}] (not (re-find #"left" name))) this can be your filter function

moizsj08:12:26

can someone explain to me how does supplying mixin maps via 'extend' allow implementing one function at a time? (of the protocol

moizsj08:12:02

as far as i understood, even if i use mixin maps, the map still needs to have all the functions of the protocol

moizsj08:12:17

if the map just has a partial set, and if later add more function keys to the map, it wont help right? since the map is immutable

naomarik08:12:34

btw @roelof would recommend http://clojurekoans.com I went through this a few days ago and was really nice to get jump started on clojure

chedgren10:12:43

There's also the adventofcode stuff.

roelof12:12:27

@naomarik: thanks, I already did the koans before trying to do this book

roelof12:12:19

where do I put these filter ??

roelof12:12:40

Any experts who can help me figure what is wrong here :

roelof12:12:48

(if  (not (re-find #"left" name))
    {:name  (clojure.string/replace (:name part)  #(str (last %1) replacement) ):size (:size part)}
    part
    ) 

mccraigmccraig12:12:12

@roelof: do you have some more context ? it's not clear what part looks like, or what result you are expecting

roelof12:12:54

I can post the whole code on refheap

roelof12:12:24

@mccraigmccraig: here you have to code : [{:name "head" :size 3} {:name "left-eye" :size 1}

roelof12:12:18

and the output must look like this :

[{:name "head" :size 3}
                            {:name "eye1" :size 1} {:"name "eye2" :size 1} ] 

mccraigmccraig12:12:17

@roelof: i'm not clear on what you are trying to do to the list of parts...

mccraigmccraig12:12:53

firstly, what do you want matching-part2 to do to a part...

roelof12:12:45

What I want is that the parts which begin with left are converted to part-1 without the left

roelof12:12:02

For the other parts nothing has to change

mccraigmccraig12:12:15

what is part-1 ?

roelof12:12:40

so {:name "head" :size 3} will be the same

roelof12:12:23

and {:name "left-eye" :size 1} must become {:name "eye1" :size 1} , {:name "eye2" :size 1} depending on the value of n

mccraigmccraig12:12:33

and where is n coming from ? is that replacement ?

roelof12:12:50

n is a number how many parts the user wants so if n = 2 then I want to have 2 eyes , if n = 3 then I want to have 3 eyes

mccraigmccraig12:12:33

but there is no n in the function matching-part2 ?

roelof12:12:49

correct the n is already used on the other function. matching part must only do the convert from left-eye to eye1

roelof12:12:11

where eye1 is the value of replacement

roelof12:12:51

I have to try and adapt a little but I could work ast first sight

mccraigmccraig12:12:53

good luck - sorry i don't have time to dig into the whole exercise... hope that was helpful

roelof13:12:28

it looks to work except I see this : {:name "left-ear", :size 1} and I want to convert that to {:name "ear1", :size 1}

roelof13:12:40

mccraigmccraig: thanks for the help

mccraigmccraig13:12:11

@roelof: i see (matching-part2 {:name "left-ear" :size 1} 10) ;=> {:name "ear10", :size 1}

roelof13:12:18

oke, then I have to change the symmetrize function somehow

roelof13:12:37

im, giving up. I cannot make the output as I like but the exercise is solved

roelof13:12:48

@mccraigmccraig: thanks for the help

agile_geek13:12:33

@roelof: do some other exercises and come back to it in a week and refactor. Amazing what not thinking about the problem for a bit does. Subconscious works on the problem in the meantime.

roelof13:12:15

@agile_geek: thanks, I will work on 4clojure and the next chapters of the brave book

roelof13:12:59

Another question on the next chapter

roelof13:12:21

I have to do (def filename "suspects.csv")

roelof13:12:43

Is there a way I can tell it's in the resources directory

roelof13:12:01

or can I only do that on a read function like slurp

agile_geek14:12:15

@roelof: to read a resource I tend to use io/resource like so:

(read-string (slurp (io/resource file)))

roelof14:12:17

oke, I have to read a whole csv file which resist in the resource directory

agile_geek14:12:30

This will look in your resources dir if you are using lein and project.clj.

roelof14:12:04

according to the book (slurp filename) is enough but I see then a message that the file is not found

agile_geek14:12:47

If you use slurp on it's own you need to specify the filename relative to project home dir.

agile_geek14:12:00

If you do it using io/resource you dont

roelof14:12:42

so I can use io/resource only on the slurp part not on the part where I define the name of the file

agile_geek14:12:53

Also if you package the app as a standalone jar using lein uberjar later it will copy the resources dir to the root of the jar so if you specified the filename as 'resources/suspects.csv' it would work from lein repl but not from java -jar <name-of-project.jar>

agile_geek14:12:49

You can do this

(def filename (io/resource "suspects.csv"))

agile_geek14:12:35

BTW io is defined as this (:require [ :as io])

roelof14:12:39

oke, and then read it with only slurp filename

roelof14:12:44

I know that

roelof14:12:01

thanks , problem solved and clear

agile_geek14:12:24

So advantage to using resource is that you can use same filepath for resources dir and the root of the jar

roelof14:12:47

then I can work through the chapter core-functions-in-depth of the brave and truth book

agile_geek14:12:05

using slurp and just string for filepath would mean changing the filepath between the repl and the jar.

agile_geek14:12:21

Got to go back to work now. Good luck.

roelof14:12:43

so I learn every day new things

roelof15:12:37

I think on clojure you never stop learning. I learn as a beginner every day new things

roelof15:12:39

@agile_geek: thanks again. I can now start on the challenges

polymeris17:12:28

Hi! What would be a cleaner way of doing this?

(:require [clj-time.core :as t])
;...
(let [t0 (t/now)] (t/date-time (t/year t0) (t/month t0) (t/day t0) (t/hour t0)))

roelof17:12:14

one maybe stupid beginners question. How can I make a vector of records so the new entry will be appended at the end. here is the code :

(defn append
  "append a new suspect to the database"
  [name glitter-index records]
  (conj records {:name name :glitter-index glitter-index})
  ) 

polymeris17:12:14

that is, getting the current date but rounded to the hour

agile_geek17:12:30

@polymeris: it's not shorter but you could use a formatter to format the date an hour.

(def custom-formatter (f/formatter "yyyy-MM-dd hh"))
then coerce it back to date-time.

agile_geek17:12:46

takes a lot more lines of code though

polymeris17:12:10

yeah and it's probably heavier, having to parse strings

agile_geek17:12:31

I think what you are doing maybe most succinct and efficient.

roelof17:12:51

this gives a error message :

(conj vec (records {:name name :glitter-index glitter-index})) 

polymeris17:12:15

is records already a vector?

agile_geek17:12:28

Just what I was going to ask

roelof17:12:00

nope record is a map

agile_geek17:12:19

@roelof: and what do you want the output to be?

roelof17:12:24

but now the new entry is added to the front and I like to try to add it in the end

polymeris17:12:55

oh... it's a list of maps? and you want the new map added to the end?

roelof17:12:04

I now see this output :

({:name "roelof", :glitter-index 2}
 {:name "Edward Cullen", :glitter-index 10}
 {:name "Bella Swan", :glitter-index 0}
 {:name "Charlie Swan", :glitter-index 0}
 {:name "Jacob Black", :glitter-index 3}
 {:name "Carlisle Cullen", :glitter-index 6}) 

roelof17:12:21

and I want to add roelof at the end

polymeris17:12:30

(conj (vec records) {:name...})

polymeris17:12:23

conj appends to the end in the case of vectors but prepends in the case of lists

roelof17:12:49

@polymeris: thanks the is the answer . I put the ending ) for vectors at a wrong place

roelof17:12:36

now the challenge that I need to make a validation function for input name and input schould not be empty

roelof17:12:05

IM thinking something like (and (not(empty? {:name :name} )) (not(empty? {:glitter-index glitter-index}))

roelof17:12:15

lets try in repl if this works

rantingbob17:12:45

@roelof: You are at the same point as me 😄 I think the exercise also requires a verification function to be ran for each element, which will be passed in as a map of keywords to function names to call

roelof18:12:44

oke, so first a check for names and then a check for gitter-index so a nested if @rantingbob

roelof18:12:23

@rantingbob: I had this :

(defn validate
  "looks if name and glitter-index are not empty"
  [name glitter-index]
  (if (and (not(empty? {:name :name} ))  (not(empty? {:glitter-index glitter-index})))
    (append name glitter-index (mapify (parse (slurp filename))))
  (println "input cannot be valided"))
) 

roelof18:12:59

but then (validate "" 2) is validaded good and beging added so this is not good

roelof18:12:05

and when I change it to this (if (and (not(empty? name )) (not(empty? {glitter-index}))) I see this error message: CompilerException java.lang.RuntimeException: Map literal must contain an even number of forms

polymeris18:12:07

why (empty? {:name :name}) and not just (empty? name)?

polymeris18:12:58

also de morgan's law

rantingbob18:12:18

Also, and this might be a style thing, but that validate function is both doing the append, and the mapify and printing out an error

rantingbob18:12:39

Personally, I'd only have it validate the entries, then return true or false if it's valid or not

rantingbob18:12:12

so you could go (when (valid entry) (append entry))

roelof18:12:28

@rantingbob: I m trying that way

roelof18:12:57

I have this now :

(defn validate
  "looks if name and glitter-index are not empty"
  [name glitter-index]
  (if (or (:name name) (:glitter-index glitter-index))
    (println "validated")
    (println "not validated")
    )) 

roelof18:12:27

but it gives not validated when im doing `(validate "roelof" 2)

roelof18:12:41

which schould output validated

polymeris18:12:23

(:name name) expects a map as name

polymeris18:12:38

you probably want (empty? name)

roelof18:12:55

oke, when I do (validate "roelof" 2) it worked fine . When I do (validate "" 2) I still see the message validated

rantingbob18:12:16

yeah, it should be and, right now it says "if either of these things are true the entry is valid"

rantingbob18:12:33

you want "if both of these things are true"

polymeris18:12:13

(not-any empty? '(name glitter-index)) is also a possiblity

roelof18:12:28

if I changed the or to and I see also the same output (validate "" 2) is validated

cjmurphy18:12:39

@agile_geek: In your customer-formatter, what does f resolve to, what is it?

roelof18:12:39

@cjmurphy: are you asking in the right channel. as far as I can see agile-geek has not posted a question for some time

roelof18:12:46

@cjmurphy: is it right that "" is not the same as a empty string ?

cjmurphy18:12:52

Well from Java or anywhere else "" is indeed the empty String - that's always been my understanding of the term.

roelof18:12:14

oke, then I wonder why (validate "" 2) is validated on this function (and (or (empty? (:name name)) (empty?(:glitter-index glitter-index)))

cjmurphy18:12:04

Perhaps you are asking if it is empty but nil is being returned??

cjmurphy18:12:28

I was just looking at (empty? (:name name)), maybe (nil? (:name name)) would be the way to go??

cjmurphy18:12:14

Hmm - I prolly s/not be commenting as don't understand these problems - but you did ask.

polymeris18:12:08

if name is a string, you don't want (:name name)

polymeris18:12:26

that would be treating it as a map and trying to get the key :name from it

polymeris18:12:13

Anyone has an idea on how to express this cleaner:

(fmap #(reduce (fn [acc x] acc (:f x)) 0 %)
      {:a '({:f 1 :b 10} {:f 2 :b 20} {:f 3 :b 30})
       :b '({:f 4 :b 40} {:f 5 :b 50})})

polymeris18:12:57

I need to get the sum of the :fs for each item (`:a`, :b,...) in the map

roelof19:12:50

pff, I begin to think FP is not for me . Also this is not working :

(defn validate
  "looks if name and glitter-index are not empty"
  [name glitter-index]
  (if (and ( not (nil? name)) (not (nil? glitter-index)) )
    (println "validated")
    (println "not validated"))
    )

roelof19:12:15

it gives validate on both (validate "roelof" 2) and (validate "" 2)

cjmurphy19:12:51

Maybe you want blank?

rantingbob19:12:57

(if (and (not (empty? name)) (not(nil? flitter-index)) valid invalid) should work I blieeve

rantingbob19:12:07

thing to remember, an ampty string isn't nil or falsy

rantingbob19:12:20

I don't know if its empty either, I think that refers to collections

rantingbob19:12:37

yeah you want blank

rantingbob19:12:25

(defn validate "looks if name and glitter-index are not empty" [name glitter-index] (if (and ( not (clojure.string/blank? name)) (not (nil? glitter-index)) ) (println "validated") (println "not validated")) )

rantingbob19:12:32

I think that works, pardon poor formatting

roelof19:12:48

Thanks, the line you post is working. I had to use empty? for the name and nil? for the index

rantingbob19:12:09

blank for the name and nil for the index

rantingbob19:12:40

nil? specifically checks if a value is nil, empty? checks if a sequence is empty, blank? checks if a string is blank

polymeris19:12:59

i can't find blank? in the docs

rantingbob19:12:07

(:name name) didn't work because name was a string, and you can't take a keyword out of a string

roelof19:12:11

oke, empty works for me if I do (validate "" 2) . it gives not valid

polymeris19:12:27

oh, it's in clojure.string...

rantingbob19:12:36

check out http://conj.io for a quick cheatsheet

Chris O’Donnell19:12:10

@polymeris: what is it you want your function to return? {:a 6 :b 9} ?

Chris O’Donnell19:12:00

(into {} (map (fn [[k v]] [k (reduce + 0 (map :f v))]) m)) is a decent solution, I think. I named your map m.

rantingbob19:12:43

hah...I was getting there too. Just had to install lein on my windows machine...you beat me to it 😛

Chris O’Donnell19:12:53

Perhaps #(get % :f 0) would be more robust, instead of just :f

rantingbob19:12:55

I'm curious how you got to it...what was the thought process?

rantingbob19:12:20

Mine was "I need to sum all of the :f in each val in the map so I'm going to 'map extract-and-sum-f m'" then for extract and sum I'm probably doing something like 'reduce + get-all-fs' where gett-all-fs is something like 'map :f v'

rantingbob19:12:24

If that makes sense

Chris O’Donnell19:12:47

I usually think from the inside out. First, I wanted to turn the maps into their :f value. And do this for all of the maps for a particular key, so (map :f v).

rantingbob19:12:51

then I'm going to massage that into a new map

Chris O’Donnell19:12:53

I need to turn those numbers into their sum, so the reduce, and I want to do that for each [k v] pair in the hash-map, which brought me to my outer map call.

Chris O’Donnell19:12:03

Since map returns a seq, we turn that back into a map with into {}

rantingbob19:12:30

interesting that we both came at it from different directions

Chris O’Donnell19:12:31

We had a similar thought process, I think.

rantingbob19:12:42

we did, but you went inside out and I went outside in

rantingbob19:12:58

interesting exercise simple_smile

Chris O’Donnell19:12:13

I think inside out because I can check my steps more easily in the repl.

Chris O’Donnell19:12:31

If I try to do it all at once, I usually make mistakes and have a harder time checking.

polymeris19:12:09

I like the (reduce + 0 (map :f v)) part... but will keep the fmap i think

rantingbob19:12:27

So, i'm pretty new, whats the benefit of fmap?

polymeris19:12:56

it's just more succint, I think

roelof19:12:58

next exercise also a problem. I have to convert the map back to the orginal strings.

roelof19:12:15

So I thought this would work :

(defn convert-back
  "convert the map back to strings"
  [records]
  (map (fn [it] (clojure.string/join it) records ))
  ) 

Chris O’Donnell19:12:40

@polymeris: what does fmap do? I haven't encountered it before.

roelof19:12:43

but then I see this output : "clojure.core$map$fn__4549@5ee9d08f"

polymeris19:12:51

fmap is not built into clojure, tho... which is weird in my opinion

roelof19:12:20

IM gettting tired . Every exercise of 4clojure or brave is a fight 😞

Chris O’Donnell19:12:04

Don't be too hard on yourself @roelof. Getting used to functional programming solutions to problems is quite challenging; you really have to think in different ways.

rantingbob19:12:31

@roelof: think about what map does, what you are doing there is looping over each map in your vector of maps and calling str.join. so if you have { [1 2] [a b]} you are trying to join [1 2] to [a b] when you want to be joining the contents of those vectors

polymeris19:12:44

fmap applies a function to every value of a map

rantingbob19:12:49

You are on the right lines, you just need to join the vectors contents too

polymeris19:12:54

and returns a map of the results

rantingbob19:12:14

so its a wrapper around (into {} (map f...

rantingbob19:12:16

@roelof: so yo uwant to be doing something like (map (join-with-newline) (map (join-with-comma) m))

rantingbob19:12:30

so first you create a sequence containing [1 2] and [a b] as strings ["1,2" "a,b"} then you reduce (not map) over that, joining them toghether

rantingbob19:12:37

I think that makes sense simple_smile I'm just as new as you so this might be the blind leading the blind 😄

roelof19:12:58

oke, I tried this (map (fn [{:name name :gitter-index gitter-index}] (clojure.string/join name gitter-index )) records )) but now gitter-index in the anymous function cannot be resolved says cursive

rantingbob19:12:19

I think thts because you have your function arguments incorrect. Don't worry about destructuring the argument for the moment. I would just take an entry and work with that

rantingbob19:12:00

so (fn [entry] (clojure.string/join "," (vals entry))

rantingbob19:12:13

you get the vals from the entry, and join them with ","

roelof19:12:01

oke, a little bit further . if I do (map (fn [it] (clojure.string/join (:name name) )) records ) I see this : ("" "" "" "" "")

rantingbob19:12:38

because it should be (:name it)

rantingbob19:12:58

and you should probably give it a seperator

rantingbob19:12:06

check the docs on http://conj.io for an idea what it needs to take

roelof19:12:40

I checked the docs and I do not get it working. I have now this (map (fn [it] (clojure.string/join (:name it) (:gitter-index it) ) records ))

roelof19:12:29

when I do (string/join "," (:name it) (:gitter-index it)) then I see a arity error

roelof19:12:31

somehow I have to put the name and gitter-index in a []

roelof19:12:56

and this (map (fn [it] (clojure.string/join "," [(:name it) (:gitter-index it)] ) records )) gives a object

rantingbob19:12:19

yeah, string join expects a collection

rantingbob19:12:32

so rather than getting the values independently, just get them as acollection

rantingbob19:12:40

(vals it) should do the trick I believe

rantingbob19:12:21

That way your working with the abstraction and it doesn't matter if it has :name or what have you in it

rantingbob19:12:53

Do you have a repl?

roelof19:12:22

yes, it work the whole time in repl

roelof19:12:42

this seems to work : (map (fn [it] (clojure.string/join "," (vals it) )) records ) only I see a set

rantingbob19:12:35

If I ever get stuck like this I susually try to think in smaller chunks and work in the repl. I'll def some temporary to (first records) and get a function that joins them. Then I'll play with map to get a sequence of joined strings, then I'll work with reduce to get a single joined string

rantingbob19:12:56

rather than trying to solve the whole thing at once. Then I'll usually refactor it top down if I can

rantingbob19:12:09

I do only tend ot think about it bottom up like that if I get stuck though

rantingbob19:12:38

I'm pretyt sure map always returns a seq?

roelof19:12:16

yep, Im also sure

roelof19:12:54

@rantingbob: oke, this part is working (clojure.string/join "," (vals {:name "Edward Cullen", :glitter-index 10} ) )

roelof19:12:15

tommorrow thinking how I can do this for more then 1 record

roelof19:12:22

Now too tired.

roelof19:12:33

thanks for the help

roelof19:12:50

I think map or reduce schould do the trick

rantingbob19:12:08

hah. Fair. No problem. And you're going to reduce, join, onto a blank string.

roelof20:12:19

oke, can I use the function that works as the function

roelof20:12:37

@rantingbob: then I think I know how to make it work

rantingbob20:12:50

You should be able to yes

rantingbob20:12:45

well...(reduce (join-with-newline) "" (map (the-above-function-that-joins-with-comma) m))

rantingbob20:12:48

so (map (join-with-comma) m) should return you a seq containing all your "rows" with there contents joined by commas

roelof20:12:59

oke, that way then I was not right

rantingbob20:12:05

then you need to reduce over that seq putting together your final string

rantingbob20:12:15

Yeah I think I missunderstood your question

roelof20:12:28

pff, and this schould be the the easy chapters

rantingbob20:12:52

its a very different way of thinking if you've only programmed with imperative languages or OOP before

roelof20:12:06

yes, I did erlang and a lot of ruby before this

rantingbob20:12:08

It's worth it though. Once you get it it's quite a bit of fun, and oh god you write so much less code

roelof20:12:42

so I have to think how to join with the newline. I do not think I can use it on both functions

roelof20:12:10

I did a lot of 4clojure but there the first challenges are not so hard

rantingbob20:12:14

first worry about getting ( "joined,string" "joined1,string1" etc.)

rantingbob20:12:54

Then worry about turning that into "joined,string/njoined1,string1"

roelof20:12:18

I mean that in the join with the "," need to be a argument of the join with newline

rantingbob20:12:23

as I say, I would first worry about getting each record joined yb commas in a single string

rantingbob20:12:33

stupid fingers

rantingbob20:12:44

first worry about getting each record joined by commas into a single seq

rantingbob20:12:01

then work out how to turn that seq of strings into a new string joined by newlines

roelof20:12:07

oke, thanks

roelof20:12:39

I will try it tommorrow , I give up for today

rantingbob20:12:14

I hope that was helpful. I'm honestly not much further along than you are. The key is to think about data transformation, how do I turn A into B. Then try and think about abstractions. Try not to use :name etc.

rantingbob20:12:26

and think in small bites.

rantingbob20:12:41

anyway, sleep well simple_smile

rantingbob20:12:49

I promise, you'll get there and its fun

roelof20:12:58

At this point clojure is not fun

base69820:12:32

(repeatedly "bullshit")

base69820:12:54

clojure is fun simple_smile

base69820:12:46

Does the portland area have much of a clojure community? I know the conj/west was there

roelof20:12:17

at this moment I find it no fun. Every challenge is a fight and my energy is low due to a illness

base69820:12:38

remember to take breaks, burn out is real

rantingbob20:12:40

Then dude...give it a break for abit

rantingbob20:12:49

don't force it or you'll hate it

base69820:12:37

anyone know the syntax for the compojure urls? Can they be straight regex's and if so what key do the groups end up under the request?

roelof20:12:22

im going to sleep . I now so far that I have this output "Edward Cullen,10\n"

surreal.analysis22:12:30

Is there a way to route a multifn with a wildcard / variables? That is to say, if I have something like:

(defmulti an-example (fn [x y] [x y]))
Which routes to the appropriate example based on the argument vector, can I then do
(defmethod an-example [:simple _])
which would accept everything that has :simple as a first argument, ignoring the second? Or
(defmethod an-example [:complex :complex-option-1])
(defmethod an-example [:complex :complex-option-1])
which looks at both options?

lambdahands22:12:31

Hi, all. I’m genuinely stumped here. I’m using Korma to run SQL queries, and I’m wondering why this doesn’t work?

(def db (create-db (mysql {:db “my_db" :user "root"})))

(def users (create-entity "users"))

(with-db db (select users))

lambdahands22:12:03

I get this error: CompilerException com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.* FROM "users"' at line 1

lambdahands22:12:10

This does work, though, even as it’s supposed to be another way of writing the above:

(defdb db (mysql {:db “my_db” :user “root”}))

(defentity users)

(select users)

escherize22:12:44

I don't use korma any more, but I do use a combination of jdbc and honeysql.

lambdahands22:12:08

Yeah, I think this might be a korma bug

eggsyntax22:12:17

@lambdahands: I have a very vague memory of having run up against something like that & it turned out to be a Korma version issue -- docs were outdated on the subject, and only one syntax was supported in the newest version. Seriously, though, it's possible I'm imagining that entirely.

eggsyntax22:12:10

I see every line in your example is changing; might be worth going back & isolating the change to a single difference if possible.

lambdahands22:12:24

Yeah, I think the discrepancy lies in with-db. If I’m stuck much longer I’ll open an issue as the behavior is very odd; the error is rather esoteric as well.