Fork me on GitHub
#beginners
<
2019-11-16
>
vaer-k00:11:19

I’ve been using a lot of Elixir, and in that language you can use pattern matching to dispatch to different implementations of a function depending on the arguments. In my case right now, I just want to dispatch based on whether the first arg is a string or a list. What’s the standard way to do this?

vaer-k00:11:46

What is what I’m talking about called?

vaer-k00:11:50

polymorphic dispatch?

vaer-k00:11:48

Both multimethods and protocols seem like too much for what I’m trying to do. I assume there is something simpler?

vaer-k00:11:58

Is this preferred for something this simple?

(defn something [arg]
  (cond
    (str? arg)  arg
    (list? arg) (other-fn arg)))

hiredman00:11:39

that is fine, although it is string? not str? and seq? or sequential? is likely what you want not list?

hiredman00:11:37

but I would avoid that kind of thing, a function where an arg can be different types

vaer-k00:11:10

isn’t that the essence of a dynamically typed language?

vaer-k00:11:54

or you mean just dispatching based on type?

hiredman00:11:35

I mean it is weird to have a function that takes a string or a list as the same argument

David Pham00:11:07

multi method seems the right choice though

hiredman00:11:18

the only thing I would thing if is some really annoying apis will return a string value instead of a list containing one string

vaer-k00:11:29

that’s my situation

vaer-k00:11:46

sometimes it’s a string, sometimes its a list of strings

hiredman00:11:05

I would undo that as soon as possible, meaning take the api response and box it in a vector if it is not already a list

hiredman00:11:32

and then everything after it is fixed up doesn't have to worry about it

vaer-k00:11:49

I guess I’ll do that, but I was more interested in learning a general lesson rather than solving this specific problem

hiredman00:11:06

and box is a fairly common function to write, and it looks sort of similar to your something function

vaer-k00:11:15

But maybe that is the lesson

vaer-k00:11:20

All right thanks for your help guys

SoV402:11:23

ring middleware is kicking my ass 😄

SoV402:11:49

I want to check if the session variables are set, if so give you the app, if not give you the login screen

SoV402:11:00

but I get lots of Null Pointer Exceptions ;-;

seancorfield02:11:36

@chrysalis129 feel free to ask your beginner questions here. I have to ask : is this a class homework problem? I've seen several people ask for help with the exact same problem in various places.

Richard Desouza02:11:02

yes it is its an assignment due on sunday 😧

Richard Desouza02:11:46

if anyone can help me with debugging this that would be great

seancorfield02:11:20

That explains why your class mates are all posting the same question then 😁

seancorfield02:11:46

I'm eating right now but will be happy to help later -- or any time over the weekend

Richard Desouza02:11:04

ok sounds good 🙂

seancorfield02:11:13

Seems like everyone is struggling with it. Makes me think maybe the teacher isn't doing a very good job ...

Richard Desouza02:11:16

yea the prof usually only teaches syntax when it's not relevant to an assignment.. plus he often goes on tangents during lectures so it's hard to pay attention

Richard Desouza02:11:35

first assignment he gave = super easy and now this one super hard 😧

seancorfield02:11:04

I sympathize -- my first year comp Sci prof was terrible 🙃

dpsutton02:11:08

Is it working but taking too long?

dpsutton02:11:26

And what are y’all going over in class?

Richard Desouza02:11:34

it's not i got most of the functions to work but cities doesnt print all the csv values anymore and i'm trying to find a way to do closest-city-pairs without the use of ->>

Richard Desouza02:11:23

also theres another function i need to implement

Richard Desouza02:11:41

its to take all the :population key values from all the hashmaps in cities and sum them up some how

Richard Desouza02:11:12

im trying to map the populations to a vector but it doesnt seem to want to print too

Richard Desouza02:11:13

(defn total-population [cities] (for [x (map :pop (cities)) :let [y x]] (print y)))

seancorfield02:11:48

You have parens around cities -- are you passing in function?

Richard Desouza02:11:32

cities returns the hash map of each row in the csv file

dpsutton02:11:10

Sorry I’m down to help and explain but I still don’t see a question or what you working. Just the whole file

Richard Desouza03:11:00

ok nevermind i got the total population working

Richard Desouza03:11:09

now for the last function i need to do

Richard Desouza03:11:33

i need to print :province and :pop from all the hash maps in cities and sort them in order from smallest :pop to largest

Richard Desouza03:11:40

any idea where i can start with that?

Richard Desouza03:11:07

how would i go about printing just :province and :pop from cities(returns a vector of all hash maps in a csv file))

Richard Desouza03:11:20

also is there anyway to complete this function without using ->> and (filter large) dpsutton if i might ask?

dpsutton03:11:14

Why do you want to avoid the threading macro?

dpsutton03:11:24

And which function?

Richard Desouza03:11:22

Because theres a thread with the solution on reddit and i feel all my classmates are going to copy it so I want to find a different way to do the function

Richard Desouza03:11:28

(defn closest-city-pairs [] (let [y (->> (cities) (filter large) vec)] (for [a (butlast y) b (rest y) :when (and (not= a b) (close a b))] [(:city a) (:city b) (distance a b)])))

Richard Desouza03:11:38

i tried doing it this way

dpsutton03:11:58

Well you can remove the vec and just use (filter large (cities)) but I think the for loop is the more tell tale expression there

Richard Desouza03:11:08

but i get unsupported binding form :when

dpsutton03:11:31

What is your current version? Let’s see what’s up with the :when binding error. If I had to guess you’ve got that in the let rather than the for

seancorfield03:11:37

(I'm back from dinner and have a beer and a warm REPL!)

seancorfield03:11:46

In that for comprehension you're going still compare N-2 of those cities against themselves so I don't think you're saving much with butlast and rest -- you already need (not= a b) so you might just as well do (for [a y b y :when (and (not= a b) (close a b))] [(:city a) (:city b) (distance a b)])

seancorfield03:11:02

(since close calls distance anyway and just checks it against 600, I'd probably have :let [d (distance a b)] :when (< d 600) inside the for and then [(:city a) (:city b) d] in the body of it)

seancorfield03:11:44

(or have a predicate near? that takes a distance and check it against 600km: (defn near? [d] (< d 600)) -- then :when (near? d) in the for per above)

seancorfield03:11:43

Lots of ways to write it.

dpsutton03:11:08

You can also use (< 0 d 600) and then you don’t have to check not=

dpsutton03:11:38

Since distance is a metric distance is zero if and only if the points are the same

seancorfield03:11:46

Per @dpsutton’s comment above, since you're using for and it only cares about sequences, you definitely don't need to call vec on the filtered sequence of cities:

(defn closets-city-pairs []
  (let [large-cities (filter large (cities))]
    (for [a large-cities b large-cities
          :let [d (distance a b)]
          :when (< 0 d 600)]
      [(:city a) (:city b) d])))
Something like that?

seancorfield03:11:54

^ @chrysalis129

Richard Desouza03:11:02

thanks that helps

Richard Desouza03:11:50

okay now for some reason the distance between two cities isnt accurate anymore

dpsutton03:11:56

Use your repl with two simple cities and investigate

Richard Desouza03:11:57

nevermind it works fine scratch that

dpsutton03:11:02

You can use Pythagorean triples so the distances are nice easy numbers. (0,0) and (3,4) will give you a distance of 5

Richard Desouza03:11:58

how can i get print out a vector of hash maps that just returns the :province and :population

Richard Desouza03:11:33

if i have cities function that returns the vector with all the hashmaps and keys

seancorfield03:11:42

select-keys will help

seancorfield03:11:00

Also, if you want to map a function over a sequence and get back a vector instead of a sequence, you can use mapv (there's a filterv as well)

Richard Desouza03:11:05

ok but i need to iterate over a vector with multiple hash maps.. how do i just get the :pop and :province

Richard Desouza03:11:22

select-key doesnt seem to work if i try to pass (cities) into it

dpsutton04:11:56

Select keys takes a single map. So you can map it over a sequence of maps

seancorfield04:11:34

(mapv #(select-keys % [:pop :province]) (cities))

dpsutton04:11:47

(map inc [1 2 3]) will call inc on each item in the vector. Likewise you want to select keys for each map

seancorfield04:11:35

@chrysalis129 Some good advice about map and functions https://stuartsierra.com/2015/08/10/clojure-donts-redundant-map (when you're ready to think about idiomatic code as opposed to just working code).

Richard Desouza04:11:15

(print (mapv #(select-keys % [:province :pop]) (cities)))

Richard Desouza04:11:23

it seems to only be returning the :pop for each tho

seancorfield04:11:02

Are you sure that all the city maps have :province as a key?

Richard Desouza04:11:20

had it as :admin

seancorfield04:11:29

Administrative Region 🙂

seancorfield04:11:43

Yeah, I've seen that coming back from Google Geo APIs.

Richard Desouza04:11:22

okay so it prints like this

Richard Desouza04:11:25

{:admin Nunavut, :pop 0}]

Richard Desouza04:11:35

is it possible to get rid of :admin and :pop so it just prints the values?

Richard Desouza04:11:43

also i tried sorting it in terms of population

Richard Desouza04:11:02

(print (mapv #(select-keys % [:admin :pop]) (cities)) (sort-by :pop))

Richard Desouza04:11:34

its giving me wrong number of args passed thgo

seancorfield04:11:30

(mapv vals coll) will give you sequences of just the values from hash maps

seancorfield04:11:29

You might not always get them in the same order tho' since hash maps are unordered. If you always want :admin then :pop, you might look at the juxt function

seancorfield04:11:26

(mapv (juxt :admin :pop) (cities)) will give you a vector of vectors, each subvector containing the :admin value, followed by the :pop value.

Richard Desouza04:11:38

okay yeah that works

Richard Desouza04:11:47

ok it goes from largest population to lowest

Richard Desouza04:11:54

where do i put sort-by to flip it?

seancorfield04:11:32

You can either sort the city collection, then map over and select just the two fields, or you can do it the other way around.

seancorfield04:11:51

In the first case you would sort-by :pop since you have hash maps with the key :pop

seancorfield04:11:14

In the second case you would sort-by second since you now have vectors with the population in the second position

vinurs04:11:16

is there any function that can parse 20% to 0.2?

seancorfield04:11:46

How is 20% represented @haiyuan.vinurs ?

seancorfield04:11:17

(if it's just an integer -- 20 -- you can just divide by 100, or by 100.0 if you specifically want a double result rather than a ratio)

Richard Desouza04:11:48

ok i tried doing the first option sean

Richard Desouza04:11:56

its saying im giving the wrong number of inptus tho for my function

Richard Desouza04:11:58

(defn provincial-population [] (let [y cities] (sort-by :pop) (mapv (juxt :admin :pop) (cities)) ))

seancorfield04:11:23

(sort-by :pop coll) <-- needs a collection

seancorfield04:11:08

Remember that Clojure is a) expression-based and b) all immutable. Sorting produces a new collection that is a sorted version of the input collection.

vinurs04:11:20

@seancorfield i read the string 20% from file, so i need to parse it

seancorfield04:11:44

So you're either going to have (sort-by ... (mapv ... (cities))) or (mapv ... (sort-by ... (cities)))

seancorfield04:11:15

->> can make the order of operations clearer, if you want.

seancorfield04:11:26

@haiyuan.vinurs so you have "20%" as a string?

Richard Desouza04:11:21

ok i got it to print

Richard Desouza04:11:28

but its still doing largest populations first

Richard Desouza04:11:31

(defn provincial-population [] (let [y cities] (sort-by :pop (mapv (juxt :admin :pop) (y))) ))

vinurs04:11:51

now i want convert the string 20% to float 0.2

seancorfield04:11:26

@chrysalis129 Read what I said above about the order of sort and select keys. You're trying to sort on :pop after you've produced a vector of vectors.

seancorfield04:11:32

@haiyuan.vinurs are you guaranteed all the values are <some sequence of digits> always followed by %? If so, you could just do a substring operation to remove the last character, then parse it as a long, then divide by 100.0

seancorfield04:11:49

(Long/parseLong "20") will produce 20, for example.

Richard Desouza04:11:18

thanks that worked sean

Richard Desouza04:11:28

Much love to you guys here 🙂

Richard Desouza04:11:32

finished my assignment

Richard Desouza04:11:41

this is a great place

seancorfield04:11:43

Assignments are never "finished" 🙂

seancorfield04:11:08

Let us know how the marking goes on it.

Richard Desouza04:11:51

I will 🙂 thanks again

Richard Desouza04:11:27

actually im not done my apologies -_-

Richard Desouza04:11:44

i just realized we have to sum up each province because theres hash maps with the same province

jaihindhreddy06:11:12

You can write a helper fn map-vals that take a fn and a map and returns a new map with the fn applied to each value in the input map. Like this:

(defn map-vals [f m]
  (into {} (map #(update % 1 f)) m))
You then have to group the cities by province and use map-vals to turn those collections of cities into the sum of population, then sort that. Like this:
(->> (group-by :province cities)
     (map-vals #(apply + (map :pop %)))
     (sort-by (comp - val)))
This will give you provinces sorted in decreasing order of population.

Richard Desouza07:11:38

the function isn't allowed to have any parameters unfortunately 😧

jaihindhreddy07:11:31

Who's restricting you from having parameters on that function?

Richard Desouza04:11:52

and then sort that

Richard Desouza04:11:40

i think ill need a for loop yea?

dpsutton05:11:17

Excellent time to look into reduce

dpsutton05:11:57

Or you could look into group-by

Richard Desouza07:11:55

(defn distinct-provincial-population [] (for [[p xs] (group-by :province (cities))] [p (reduce + (map :pop xs))])) is what i got so far

Richard Desouza07:11:00

any ideas how to proceed from there

seancorfield07:11:28

Sounds about right -- but isn't it :admin rather than :province?

ho0man09:11:30

Hi, everyone I keep running into a problem with records and protocols : We have a couple of protocols in separate namespaces, the record implementing those protocols resides in a separate ns. Whenever I uberjar and import it as a lib in another project it gives the exception : *no impelmentation of method ... of protocol ... found for class*. Is there sth I am missing about protocols & records? Does it have to do with which ns s are imported where I am using them?

alexmiller13:11:31

Probably. You need to load (require) any namespaces that contain implementations before you can use them

ho0man13:11:21

I imported the record and the exception went away. (The namespace containing the implementation was already required). Do I always have to import the record or there is some other thing at work here?

alexmiller14:11:19

It depends what you’re doing but you should not generally need to import

SoV414:11:20

I have a middleware for checking logins, I want to check the session variable and redirect to login if it's not set

SoV414:11:31

but i'm stuck in an infinite loop of login checking middleware

SoV415:11:45

actually it seems to work now but i keep getting null pointer exceptions on RegEx matches

inchingforward15:11:44

I'm having a beginner moment. Why does the following always return "dunno"?

(defn color->name [color]
  (case color
    "#ffffff" "white"
  	"#000000" "black"
    "dunno"))

inchingforward15:11:54

Using a switch case in Java "works". How is Clojure seeing the "#" differently?

SoV415:11:13

try it without the dunno and see if you get "no matching clause"

SoV415:11:39

Actually your code works for me when I put in "#ffffff"

SoV415:11:54

jpdrills.server=> (defn color->name [color]
             #_=>   (case color
             #_=>     "#ffffff" "white"
             #_=>       "#000000" "black"
             #_=>     "dunno"))
#'jpdrills.server/color->name
jpdrills.server=> (color->name "#ffffff")
"white"
jpdrills.server=>

inchingforward15:11:14

Ok, so I just copy/pasted it again, and now it's working for me.

tws15:11:26

not your question, but why not just make a hashmap of it, then use that as a function?

SoV415:11:50

@tws makes a great point, could you provide an example for our new friend?

tws15:11:06

(def color->name {"#ffffff" "white", ...})

tws15:11:45

(map color->name color-coll)

tws15:11:10

you’ll have nil instead of "dunno"

inchingforward15:11:24

I like that solution. I was just confounded why it wasn't working for me.

tws15:11:53

you’re calling the old function

inchingforward15:11:00

I found my problem!

inchingforward15:11:06

Thanks for the help. 😀

SoV415:11:48

Wow I was missing an end-brace in my one authentication handler

SoV415:11:56

err it was misplaced in the map, the ending }

SoV415:11:23

So yeah! don't pull out your hair if you have been working all day and you suddenly "break everything" you probably accidentally put an ending brace } someplace inopportune and you can find it with clear eyes in the morning.

SoV416:11:18

Is it possible to do (swap! jpc-users-atom update-in [email :kanji-stumbles] conj kanji) and then simply do (swap! jpc-users-atom update-in [email :kanji-stumbles] disj kanji) to remove one?

dpsutton16:11:02

Ignore swap. Does the day structure you’re updating allow conj and disj?

dpsutton16:11:00

If it’s a set, then yes.

dpsutton16:11:04

Swap just calls your function on the value of the atom. You can test everything outside of atoms and swapping and then know it will work in the context of atoms

tstirrat19:11:12

can someone help me troubleshoot flycheck-clj-kondo? i've got flycheck installed (`M-x fly` brings up flycheck commands), I've got clj-kondo on my $PATH as evidenced by being able to fun it from the command line, but it's not doing any linting

tstirrat19:11:34

M-x flycheck-verify-setup shows "no checkter to run in this buffer"

tstirrat19:11:59

and running clj-kondo --lint my-source.clj returns 0 without seeming to have done anything

tstirrat19:11:07

is there not a default configuration for clj-kondo?

borkdude19:11:35

@tstirrat what operating system are you on? what do you see when you do which clj-kondo and clj-kondo --version?

tstirrat19:11:20

➜  ~ which clj-kondo 
/usr/local/bin/clj-kondo
➜  ~ clj-kondo --version
clj-kondo v2019.10.11-alpha

tstirrat19:11:24

this is on ubuntu

borkdude19:11:37

can you maybe first upgrade to the newest version?

borkdude19:11:51

and how did you install this version?

borkdude19:11:40

The install script should work.

borkdude19:11:57

Can you upgrade and do clj-kondo --version once again?

tstirrat19:11:35

installation script

tstirrat19:11:39

i suppose i could try yarn/npm

Richard Desouza20:11:56

so i tried implementing this and have been trying to sort it from least to most

Richard Desouza20:11:57

(for [[p xs] (group-by :admin (cities))] [p (apply + (map :pop xs))]))

Richard Desouza20:11:09

but when i try applying sort-by in the manner i did before i get wrong number of args error

Richard Desouza20:11:10

(for [[p xs] (group-by :admin (cities))] [p (apply + (map :pop xs (sort-by :pop)))]))

SoV420:11:47

sort-by requires a key-fn for comparison

SoV420:11:24

you could take the result you have from the for loop and wrap that whole result in (sort-by > val ... )

SoV420:11:41

basically it needs to know what you think matters for sorting

Richard Desouza20:11:46

dont know what u mean

Richard Desouza20:11:51

but i tried adding cities

Richard Desouza20:11:02

but its still largest to smallest

SoV420:11:12

flip the operator

dpsutton20:11:28

You have (sort-by :pop). There is no collection in that function call

dpsutton20:11:10

And if you sort it and then map and sum everything the sort is unnecessary

SoV420:11:27

right, the order of operations works from inside-out, so if you want it sorted you need to put sort-by on the outside

Richard Desouza20:11:46

(for [[p xs] (group-by :admin (cities))] ((sort-by :pop (cities)) [p (apply + (map :pop xs ))])))

Richard Desouza20:11:54

getting arrayseq cannot be cast to lang.ifn

SoV420:11:34

is cities a (function) ?

SoV420:11:16

what's the latest line of code you had that was working?

Richard Desouza20:11:30

(for [[p xs] (group-by :admin (cities))] [p (apply + (map :pop xs))]))

SoV420:11:09

nice, it has a result you like, but it's not sorted correctly?

Richard Desouza20:11:21

its sorted from largest to smallest

Richard Desouza20:11:25

need smallest to largest

SoV420:11:31

what does the result look like my friend?

Richard Desouza20:11:06

oh yea its not even sorted

Richard Desouza20:11:12

it just lists the provinces

Richard Desouza20:11:28

it adds all the hashmap province populations correctly

Richard Desouza20:11:38

just need to figure out where to put sort-buy

SoV420:11:52

Excellent work so far

seancorfield20:11:09

(sort-by second (for [[p xs] (group-by :admin (cities))] [p (apply + (map :pop xs))]))

seancorfield20:11:34

Assuming you want to sort the pairs of province / population.

dpsutton20:11:40

Say it out loud in words. “Once I compute the pairs of city name and counts, I need to sort by the population count”

Richard Desouza20:11:40

thanks sean that did it 🙂

dpsutton20:11:00

Then it’s obvious the sort goes outside of the computation

Richard Desouza20:11:05

i see so like last operation that needs to be done goes on the outside

seancorfield20:11:43

Right, because function arguments are evaluated before the function is called.

seancorfield20:11:25

(sort-by second (for ,,,))
;; evaluates (for ,,,) first
;; then calls `sort-by` on the result of that evaluation

SoV420:11:48

And what does Second do? just grabs the second parameter of each thang?

seancorfield20:11:07

Yes, because we have a sequence of pairs (province, population)

SoV420:11:11

Second in this case is the population ?

SoV420:11:13

Ah okay awesome

seancorfield20:11:53

(first pair) => province; (second pair) => total population (the sum of the population of each city within that province

seancorfield20:11:34

So it's always a pipeline of operations, starting with the innermost and working outwards.

SoV420:11:51

House.Price.Erase in clojure talk becomes (Erase (Price (House))) right?

SoV420:11:38

Collection.Second.Sort-by (Sort-by (Second (Collection))) not a perfect mapping but maybe some good examples could help illustrate how functions bloom from inside out

andy.fingerhut20:11:46

I am not sure what language that is intended to be written in. If House.Price.Erase is written in Java syntax, and if the Clojure function price takes a value of type House and returns its price, and the Clojure function erase takes a price value and does something with it, then yes, (erase (price house)) would be how you write it.

andy.fingerhut20:11:26

However the verb erase you are using in your example makes me wonder whether it is intended to remove the field/property/attribute/whatever of the object house, in which case it is unlikely that you would write the Clojure code that way.

seancorfield20:11:55

As Dan said above, say it out loud to get the order of operations -- and think about it as a single expression, rather than a sequence of imperative steps.

SoV420:11:18

mm that's true, functional does not rely so much on sequential procedure

SoV420:11:30

but in the abstract what do you want this transformation on this collection to look like

Richard Desouza20:11:37

ok so going back to a function i was doing previously

Richard Desouza20:11:51

actually nevermind

Richard Desouza20:11:55

i think im done 🙂

SoV420:11:01

Rock n Roll

Richard Desouza20:11:03

thanks for the help guys

SoV420:11:18

I owe much of my sanity to the fine chaps here.

Richard Desouza20:11:22

ill probably come back here when final exam season comes around 😛

seancorfield20:11:48

And that function composition / call ordering is also why ->> might make it easier to think about:

(->> (for ,,,) ; compute total population for each province as pairs
     (sort-by second)) ; then sort by the second element of each pair

SoV420:11:11

hey that's a great time to introduce thread-thru and double-thread-thru

Richard Desouza20:11:18

so that makes it not about order of operations?

SoV420:11:31

think of a spool of thread

dpsutton20:11:01

Is the class in clojure or just this particular homework?

Richard Desouza20:11:14

its just an assignment

seancorfield20:11:19

->> thread-last takes the expression and puts it into the last slot of each "step" in order -- turning it into the nested function call you saw above.

SoV420:11:22

clojure class would be Dope

Richard Desouza20:11:22

class is about a bunch of programming languages

seancorfield20:11:53

Which other PLs are you studying @chrysalis129?

dpsutton20:11:56

do you mind saying which institution?

dpsutton20:11:06

(Understand if you don’t want to)

Richard Desouza20:11:13

were doing scala next

Richard Desouza20:11:22

and some other stuff

Richard Desouza20:11:28

but clojure and scala most indepth

Richard Desouza20:11:44

yea sorry bout that dps 😧

dpsutton20:11:47

Well I’m glad that clojure is in curriculum somewhere :) good luck with your studies

Richard Desouza20:11:44

thanks dpsutton 🙂

seancorfield20:11:44

Scala is... interesting... I did that for about 18 months before switching to Clojure. Do you already know Java @chrysalis129?

Richard Desouza20:11:37

know it a lot better than clojure thats for sure xd

Richard Desouza20:11:52

also know python C++ node.js

Richard Desouza20:11:10

trying to learn some other frameworks so i can get a software engineering internship soon

Richard Desouza22:11:54

hello again I have one more question

Richard Desouza22:11:13

say I have a one string that is "Hello" and a second string that is "Apple"

Richard Desouza22:11:42

is there anyway I can evaluate these two based on alphabetical order something like (> firstString secondString) evaluates to true?

dpsutton22:11:08

Have you tried exactly that?

Richard Desouza22:11:25

java.base/java.lang.String cannot be cast to java.base/java.lang.Number

dpsutton22:11:56

Try compare

dpsutton22:11:35

And (doc compare)

Richard Desouza22:11:06

cant resolve doc

dpsutton22:11:15

(clojure.repl/doc compare)

dpsutton22:11:29

Not sure what your repl environment looks like sorry

Richard Desouza22:11:48

yea doesnt work either 😧

dpsutton22:11:37

How are you running clojure?

Richard Desouza22:11:14

cmd with java -cp clojure-1.8.0.jar clojure.main filename.clj

Richard Desouza22:11:45

ok thanks i got it to work xd

ghadi22:11:40

@chrysalis129 you should consider running clojure with integration in your text editor - it’s a far smoother, richer experience

ghadi22:11:50

What platform are you on?

Mattias22:11:34

Hey all, in a philosophical moment I’m interested in a comparison or discussion of Clojure to other lisps/schemes/whatevers. Doesn’t need to be syntax focused, I’m as much interested in things like developer experience, “feeling”, purpose and historical accident results of various languages. Anything, basically. Any content anywhere to recommend? 🙂

Mattias22:11:48

One specific thing... what makes Clojure Clojure, as opposed to “almost Common Lisp” (or whatever). What subset of Clojure would be somehow enough to be thought of as Clojure, if at all possible or relevant?

eggsyntax00:11:18

I imagine you may have continued on other channels, but just to give my two cents — I would say the main differences that make Clojure pretty different from something like Common Lisp are that a) clj is much more functional, whereas CL is very multiparadigm; b) clj is hosted (on the JVM, or in the case of cljs, on JS environments); and c) clj uses a wider set of first-class collection data types (ie maps, vectors, sets, lists, as opposed to just lists).

Mattias22:11:28

(Yes, vague and fluffy. Any and all replies highly welcomed 😅)

seancorfield22:11:27

@mattias504 That's probably a discussion better suited to #off-topic or perhaps #other-lisps rather than the #beginners channel (although I understand that beginners may be interested in this topic)

seancorfield22:11:59

I would seed that discussion with the material here https://clojure.org/about/rationale and here https://clojure.org/about/lisp (the latter is very short tho') -- most of the left-hand links in that "About" section are worth reading as background to your question and provide quite a bit of insight toward answers for it.

Mattias22:11:46

Thanks a lot! I’ll dive in and use other channels going forward!

andy.fingerhut22:11:30

There are also some more answers to rationale of differences between Clojure and Common Lisp or Scheme in a talk given by Rich Hickey about 2008 or so, transcript and link to video/audio here: https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/ClojureIntroForLispProgrammers.md

seancorfield22:11:16

I'll keep an eye on both of those channels for any follow-up discussion -- it's a topic that interests me (and I have some opinions but not really in-depth knowledge of other lisps).