This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-08-02
Channels
- # announcements (14)
- # beginners (133)
- # cider (27)
- # cljs-dev (7)
- # cljsjs (13)
- # clojure (105)
- # clojure-dev (58)
- # clojure-italy (1)
- # clojure-nl (17)
- # clojure-russia (33)
- # clojure-spec (5)
- # clojure-uk (154)
- # clojured (1)
- # clojurescript (35)
- # cloverage (4)
- # cursive (35)
- # datomic (58)
- # duct (8)
- # editors (9)
- # emacs (15)
- # events (1)
- # figwheel (47)
- # figwheel-main (132)
- # hyperfiddle (5)
- # immutant (29)
- # instaparse (21)
- # luminus (3)
- # off-topic (5)
- # onyx (5)
- # overtone (5)
- # pedestal (8)
- # re-frame (7)
- # reagent (6)
- # reitit (3)
- # schema (2)
- # shadow-cljs (178)
- # spacemacs (49)
- # specter (2)
- # sql (1)
- # tools-deps (110)
my CLI tools is giving me the following error: "Error building classpath. Map literal must contain an even number of forms". I can still use leiningen and boot without a problem, but it's bothering me that I can't figure this out.
that is, when trying to start a REPL.
i believe i've seen that when there's a syntactic problem with the deps.edn
@porkostomus it sounds like your deps.edn file may be malformed. neither boot nor lein will look at this file
that's what I thought, but it doesn't seem to be the issue
ah, I fixed it. didn't check the one in the .clojure folder
@porkostomus If you want lein
and boot
to also use the deps.edn
files for dependencies, there are plugins/tasks for that.
https://github.com/RickMoynihan/lein-tools-deps and https://github.com/seancorfield/boot-tools-deps
oh that's cool
Hi guys, is there a way to define a specific jdk for my project to use instead of the default one(the one in my PATH) on linux?
JAVA_HOME worked fine but it affects all projects, i guess i will do a small script to change every time i want to
@seancorfield @alexmiller Spam alert [EDIT: message was deleted, thanks Sean!]
For the record, I’m not a mod here and have no power to do anything
Oops, sorry!
Message deleted. The offender will have their account deactivated shortly. Let me know if that spam needs to be deleted from other channels.
Thanks!
bottom up, function by function through the repl
but what if I don't know what are those "bottom"... Ok context - want to try make game on clojure (clojure version of board game) just to learn... I can come up pretty easy with general structure of board, players... and it seems for me that it would be natural top-down programming, filling up gaps... like start with setup_game, setup_players, make_move, calculate_points, repeat
that's fine, but using the repl allows you to do all of that incrementally
and test out the way you've modeled it as you go
ok thanks... so I guess, all the programming will go in REPL... BTW is there some "automated" REPL tools, I mean, I do lot of repling... at some point my REPL gives what I want... at that point I would like to take 'snapshot' and wrap it into repeatable test and extract and put it aside, so I have repeatable milestone of my work?
if by automated you mean a smalltalk-like snapshot the vm and return later- that's not a typical process. it's more common that as you work in the repl, you add bits that work to your code namespaces, and then "reload" to start from the new basis of the code in your namespaces. adding library dependencies also typically requires a restart-repl, though there are ways to do it dynamically in repl.
there are workflows like this around the component, system and boot tools that are specific to those tools
hmmm can you elaborate more... how is typical (ok yours?) work... you write your imagined function(s) in the namespace, load it in REPL and try to test it, or you first figure out function in REPL and then add it to namespace and relaod it?
i personally follow a variation on the stuart's reloaded workflow: http://thinkrelevance.com/blog/2013/06/04/clojure-workflow-reloaded
write functions directly in the repl in the user namespace, exercise them with static data in vars in user, then add them to a real namespace and (reload)
if i'm working on something that opens sockets or has lifecycle, i'm usually using stuart's Component library, so will stop the components, reload, then start them up again, and continue
Cursive is great, but I haven't used it for a long time
@olekss.janis you might find this helpful https://vimeo.com/223309989
The best way to work with the REPL is to use an editor that can evaluate forms into a running REPL. So you don't type into the REPL -- you type into a file and use a hot key to evaluate each form. That way everything from your REPL session is already preserved, and it's easy to copy'n'paste pieces into test files or source files as needed.
Hey all, is it possible to rework add-node in this example so that it doesn’t stack overflow? https://gist.github.com/upgradingdave/68bf9554a92ae520a626190f7d69c9b6
the idiomatic thing in clojure would be to use a vector instead of a linked list if you want to add at the end- I don't know what the constraints of your exercise are though
thanks, @noisesmith yes, this is just for fun. If I were doing it in real world, I’d use a vector, but I was just curious if there is a way to implement this as shown … curious if there’s a technique for recursive patterns like this?
you'd need some way to lift the remaining work to be done out of the call stack and into an object in the heap. If you can create a loop/recur that tracks the work done so far and lets you replace the self call to a recur, it would eliminate the stack usage
the result will not be pretty
likely you'd end up with one of the loop bindings being a hash or vector or something holding the partial results waiting to be rolled up
makes sense, thanks much for the second pair of eyes
I am having trouble getting a nested set of values out of a lazyseq and I can’t figure out why
I’ve been using get
select-keys
etc and everything keeps returning either an empty list or nil
is there any way to debug why my attempts to get out of set of values aren’t returning?
If the inner vector always contains a single map, you could use get-in
(which supports both vectors (by index) and maps (by key):
(map
#(get-in % [:access_groups 0 :group_id])
'({:access_groups [{:group_name "saas", :group_id 1}]}))
;; (1)
does anyone have any advice on how to better reason about lazy seqs? I feel like I’m always battling laziness
nothing that you’ve talked about here has anything to do with laziness, it has to do with the fact that it’s a collection
@alexkeyes it might not be the solution here, but often in Clojure the simplest thing is to construct the data structure that makes your task easiest. There are so many good data functions, that is often the least effort way to get your result
makes a lot of sense. Unfortunately I can’t edit the way the data is structured, but the idea is certainly still valid
right, but clojure has good functions for getting the shape of data you need out of some input
in other words, simplify the function that checks / verifies / calculates, and add a data transformation before it; this usually ends up being better code in clojure
you can’t
have a branch that exits with that value (if, cond, whatever)
right, because you are not exiting with that value
a function has an implicit do
(do "" 1) returns 1
@jasonpepas what does your function look like?
So, this started by joking around with some coworkers at lunch about interview puzzles, and the "roman numerals" problem was mentioned, which I had never encountered before
gotcha. so in clojure, the last expression in a defn
is what the function will return
(and you don't want to be doing def
inside defn
@jasonpepas)
you’ll want to use let
. def
always defines a global variable in the namespace, it’s not scoped
let
would allow you to destructure the first pair out of the table easily too:
(let [[[symbl value] & more] table] ...)
where more
is essentially (rest table)
also, cond handles that nicely
oh, so actually I tried using let
, but when I used let
for table
, it said something along the lines of
Exception in thread "main" clojure.lang.ExceptionInfo: Call to clojure.core/let did not conform to spec:
In: [0] val: table fails spec: :clojure.core.specs.alpha/bindings at: [:args :bindings] predicate: vector?
(cond (= i 0) "" (= table []) "" ...)
that’s because let
has slightly different syntax than def
- it allows you to bind multiple values at once
(cond (zero? i) ""
(empty? table) ""
...)
🙂ok, I remember cond
from scheme. I tried that as well but must have messed something else up.
There's no harm in laying down a trail from "here" to "there" 🙂
yeah. because of the nested branches, if
starts to become pretty unwieldy in this program
cond
is nice because you can put all of your branches at the top level, like you did in python using if
statements and early returns
ok, now I remember the problem. how do you make cond's else execute more than one statement?
I even includuded the ... inside do :D
By the way, this is a good illustration of the big shift in mindset between, say, Python (imperative, procedural, statement-based) and Clojure (functional, expression-based).
if
is an expression in Clojure (not a statement).
yeah, actually the first implementation of the python solution was iterative, then I realized that translating it would probably be easier if it were recursive
loop
is also an expression in Clojure (not a statement) which causes a lot of confusion when getting started... along with for
also being an expression (and not really anything like a for
loop in other languages).