This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-06-16
Channels
- # announcements (33)
- # atom-editor (1)
- # aws (21)
- # babashka (174)
- # babashka-sci-dev (2)
- # beginners (59)
- # calva (4)
- # chlorine-clover (9)
- # clj-kondo (51)
- # clojars (7)
- # clojure (86)
- # clojure-czech (4)
- # clojure-europe (21)
- # clojure-france (6)
- # clojure-nl (1)
- # clojure-uk (2)
- # conjure (7)
- # core-async (3)
- # core-logic (3)
- # cursive (10)
- # data-science (8)
- # datalevin (14)
- # datomic (12)
- # events (1)
- # fulcro (5)
- # graalvm (10)
- # gratitude (3)
- # honeysql (3)
- # hyperfiddle (3)
- # introduce-yourself (4)
- # joyride (3)
- # leiningen (3)
- # malli (13)
- # minecraft (15)
- # music (1)
- # off-topic (40)
- # pathom (16)
- # polylith (28)
- # portal (25)
- # rdf (15)
- # remote-jobs (3)
- # shadow-cljs (23)
- # specter (1)
- # sql (5)
- # tools-deps (25)
- # xtdb (31)
is anyone running on VS Code with Calva
as of the last Clojure survey just under 20% or so of the Clojure community uses it. Far better to just ask a question than a question about your question. There's also #vscode and #calva channels specific to the editor and tooling
Is there any way to get a REPL while debugging in Idea? For instance, if I set a breakpoint to line 103, and then debugger pauses at line 103, I want to type stuff at the repl like this:
my-project.core=> (get-in my-map [:key1 :key2 :key3])
Is this possible?That might be a better question for #cursive since it is tool-specific. In general, that sort of thing depends on how breakpoints are handled. There are ways to have exception handlers start REPLs inside the program but there are generally a lot of caveats around it. I think there have been some conference talks about it over the years, although I'm not sure what to search for to find those...
Personally, I haven't used a step debugger and breakpoints in years... maybe not in decades... I used to use that approach with C and C++ and a little bit when I first started with Java but haven't felt the need for it since then, and never with Clojure. There are lots of debugging libraries that let you capture local environments, start REPLs, send values to additional visualization tools (REBL, Reveal, Portal). Given Clojure's dynamic nature, I find it easier to just instrument specific functions where I would have used breakpoints in C/C++.
I use cider debugger all the time and I find it very useful. It has a way to evaluate expressions when the program is stopped at a breakpoint but it it's not as convenient as typing into normal buffer or repl. Intellij has a way to evaluate expressions while the program is stopped but I don't know how well that is integrated in Cursive because I don't use Cursive
Hello, what am I missing with this regex? I expect a separate string for each markdown link, but I get one string in the seq.
The problem is that \[.*\]
is "greedy" and matches from the first [
to the *last* ]
. You can get around that by using \[[^\]]*\]
instead.
Or you can use the non-greedy match \[.*?\]
user=> (re-seq
#_=> #"\[.*?\]\(\)"
#_=> "more text [Link 1]() more text [Link 2]() more text")
("[Link 1]()" "[Link 2]()")
user=>
Ah thanks sean, I was missing that concept. I will try it!
Regex is hard.
Yeah. I'd like to get a better general understanding of all the concepts. Do you have any resource/reading recommendations?
Unfortunately, no. All I know about regex I've learned via Bing (and Google before that).
I will say it's important to make sure you're reading about the Java regex implementation and not other languages' regexes tho' -- there are some subtle and important differences at times...
Oh I see. Well thank you! I didn't think to reference the Java regex docs.
I've found https://regex101.com/ to be useful when puzzling through regexs. There are a few tools like this out there, this one does have the Java flavour available
there's a really amazing resource for reqular expressions - covers all major flavors including java: https://www.regular-expressions.info/
it's where I learned about free-spacing mode, which I love https://www.regular-expressions.info/freespacing.html
(def input
(str "more text [Link 1]()"
" more text [Lin k 2]()"
"more text"))
(def regex
#"(?x) # free-spacing / comments enabled
\[.*?\] # starts with [....] describing link
\(\) # continues with (...) containing link")
(re-seq regex input)
Awesome, thanks robertftw and noisesmith!
I'd like to reduce output of db reads when testing. So given:
(defn pull [db id]
;; ...
{:pull-result pull-result :pulled-ids pulled-ids})
(defn test-pull [db id]
(let [{:keys [pulled-ids]} (pull db ids)]
{:pull-result pulled-ids ;; note
:pulled-ids pulled-ids}))
I'd like to be able to do something like this (which obviously can't work):
(with-redefs [pull test-pull]
...)
How can I achieve this? Just redefining pull
to identity
is no good.(defn pull [db id]
;; ...
{:pull-result pull-result :pulled-ids pulled-ids})
(let [origin-pull pull]
(with-redefs [pull (fn [db id]
(let [{:keys [pulled-ids]} (origin-pull db id)]
{:pull-result pulled-ids ;; note
:pulled-ids pulled-ids}))]
(pull ...)))
try thisquick question about ##
. I only see it in the the context of ##Inf ##-Inf ##NaN
.
is ##
used for anything else? what does it actually mean?
thanks all ๐
Hey, I'm trying to parse a document with instaparse, but I'm currently stuck parsing multiple lines. This is my grammar so far:
document = line
line = (<spaces*> word)* <eol>
eol = spaces* ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'
but when I change the first line to parse multiple lines
document = line*
I get this as output
[:document
[:line [:word "this"]]
[:line]
[:line [:word "is"]]
[:line]
[:line [:word "line1"]]
[:line]
[:line [:word "this"]]
[:line]
[:line [:word "is"]]
[:line]
[:line [:word "line2"]]]
does anyone know what I do wrong here? Any help is appreciated ๐starting a ๐งต
this seems to work:
document = line*
line = (<spaces*> word)+ eol
eol = spaces* ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'
for this input:
Helloworld!
asdfa
asdfa
asf
document = line*
line = (spaces* word spaces*)+ eol
eol = ('\n' | Epsilon)
spaces = ' '*
word = #'[\S]+'
this worksok, I also got this to work:
document = line* lastline
lastline = (<spaces*> word)+ (eol | Epsilon)
line = (<spaces*> word)+ eol
eol = ' '* ('\n')
spaces = ' '*
word = #'[\S]+'
basically, every line must have a newline except the last line
for your most recent example, there are multiple valid parsers and some of them aren't right
ah cool, I tried something similar but ditched it because the actual grammar inside the line is more complicated and I didn't want to repeat the rules just for the last line ๐
Epsilon is just the empty parser. Trying to find if there's some that matches something like EOF
this seems to work:
document = line*
line = (<spaces*> word)+ (eol | EOF)
eol = ' '* ('\n')
spaces = ' '*
word = #'[\S]+'
EOF= #"$"
instaparse is awesome, isn't it? I wish I could use it more often to get fluent with it ๐
document = line*
line = (<spaces> word)* <eol>
eol = spaces ('\n' | #'$')
spaces = ' '*
word = #'\S+'
I would probably still go with something like:
document = (line-content <eol>)* line-content (<eol> | Epsilon)
line-content = (<spaces*> word)* spaces*
eol = '\n'
spaces = ' '*
word = #'[\S]+'
if you remove the <> you can see exactly what instaparse parsed and matched for each production
starting a ๐งต
in a regex?
"\n" is new line ...