This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-01-26
Channels
- # announcements (1)
- # asami (7)
- # aws (3)
- # babashka (30)
- # beginners (21)
- # calva (48)
- # cider (11)
- # clj-commons (5)
- # clj-kondo (12)
- # cljdoc (5)
- # cljfx (1)
- # cljs-dev (32)
- # cljsrn (4)
- # clojure (218)
- # clojure-europe (88)
- # clojure-nl (11)
- # clojure-uk (31)
- # clojurescript (8)
- # cursive (98)
- # data-science (6)
- # datomic (49)
- # emacs (12)
- # events (4)
- # fulcro (47)
- # graalvm (3)
- # graphql (4)
- # introduce-yourself (5)
- # java (13)
- # juxt (9)
- # lsp (74)
- # meander (3)
- # membrane (4)
- # missionary (31)
- # off-topic (24)
- # pathom (41)
- # portal (4)
- # reagent (3)
- # releases (1)
- # remote-jobs (3)
- # rewrite-clj (4)
- # shadow-cljs (10)
- # slack-help (2)
- # testing (20)
- # tools-deps (43)
I have a function in my code as below which is prod code.. I am confused that what value get inserted to a and b , when called with `(test-hello "A" "B")
(defn test-hello
[arg1 arg2]
(let [structure (get-value input)]
(fn [a b]
(assoc {} a b))))
(test-hello "A" "B")
The return value of (test-hello "A" "B")
is a function. But why doesn't test-hello
itself use it's parameters arg1
and arg2
?
The example doesn't really make a lot of sense. Perhaps you give an example that's less redacted?
If your question of "what would be the value of a and b" was related to the function returned - well, they're just parameters so they would get whatever values you pass in to the returned function. 🙂
How do I connect to an nrepl server from the command line?
I've tried stuff like clj -p 7000
> $ clj -Sdeps '{:deps {nrepl {:mvn/version "0.9.0"}}}' -m nrepl.cmdline --connect --host host --port port Teach a person to fish, eh
and on windows yeh gotta double qoute ""0.9.0"" :P
i'm a personal fan of the following: STEP 1: create "dev" directory
$ cd /path/to/project/root
$ mkdir dev
STEP 2: create shell script
$ touch dev/repl.sh
$ chmod +x dev/repl.sh
Place the following in `dev/repl.sh`:
#!/usr/bin/env bash
script_dir=$(dirname "$0")
cd $script_dir
cd ..
clj -M:repl
STEP 3: create CLJ file to launch custom nREPL
place the following in `dev/repl.clj`:
(ns repl
(:require
[clojure.tools.nrepl.server :as nrepl-server]
[cider.nrepl :refer [cider-nrepl-handler]]
[rebel-readline.main :as rebel]))
(defn -main []
(println "nrepl server at localhost:40000")
(nrepl-server/start-server :port 40000)
(rebel/-main)
(System/exit 0))
STEP 4: add the following to your `deps.edn` aliases
:repl
{:extra-paths ["dev"]
:extra-deps
{com.bhauman/rebel-readline {:mvn/version "0.1.4"}
org.clojure/tools.nrepl {:mvn/version "0.2.12"}
cider/cider-nrepl {:mvn/version "0.22.4"}
;; add additional libs here...
}
:main-opts ["-m" "repl"]}
STEP 5: call it!
$ cd /path/to/project
$ ./dev/repl.sh
Is there someway to do doto
with an inline defined function? why does it work like this?
user=> (doto {:a 1} println)
{:a 1}
{:a 1}
user=> (doto {:a 1} #(println (assoc % :b 2)))
{:a 1}
user=> (defn foo [x] (println (assoc x :b 2)))
#'user/foo
user=> (doto {:a 1} foo)
{:a 1, :b 2}
{:a 1}
card-test=> (macroexpand '(doto {:a 1} #(println (assoc % :b 2))))
(let*
[G__192272 {:a 1}]
(fn* G__192272 [p1__192269#] (println (assoc p1__192269# :b 2)))
G__192272)