Another cool newbie question: What does Dr. Racket have that combination with Text Editor of your choice / REPL does not have?
@kamil.beker How about this? https://www.youtube.com/watch?v=R2KU0ZvIJws&t=3s
woah, thats cool
:slightly_smiling_face:
@kamil.beker: I would say: Dr. Racket is a rich environment supporting programming language research along multiple dimensions. It shows this both by supporting a significant array of languages, mostly Scheme dialects, but see e.g. Dracula and ALGOL for significant exceptions, and PLT-Redex for its use as a tool for designing new languages. Also, Dr. Racket offers its own GUI environment as libraries to use, and there’s a whole Functional Reactive Programming language, FrTime, that allows you to develop GUI programs with it. In fact, I was just discussing that with @samth yesterday. For example, if you choose "FrTimefrom the "Language..." menu, then type e.g.
seconds` into the REPL, you’ll see the current seconds (since the epoch, I guess) update dynamically in the REPL history.
@kamil.beker: So maybe think of “Racket” as a language, and “Dr. Racket” as a language workbench.
@samth: Speaking of, should we elaborate the issue you created on my behalf to express the fact that something weird about frame construction is going on, where text rendering bleeds outside the frame, etc.?
Yes that would be great
With a screenshot
@samth: Also, I’m happy to help diagnose if I can, but I honestly don’t even know where to start.
@samth: OK. Let me find that issue and edit.
Done.
Great!
OK, new approach. Expressions can be manipulated, right? And a function definition is an expression, right? So I can probably make a copy of the function, search-and-replace in the datum, and paste a new, changed, function.
Something like, (define simple-tokenizer (except-with-replacement make-tokenizer "lexer-src-pos" "lexer"))
OK, what’s the syntax for “produce the datum for the function with this name”?
Newbie question: Is there a way to get the datum of a function just by using the function name?
A datum is a literal value. Like 42 “foo” ’bar. Functions do not have datums.
datums are basically code, right?
No.
Well, depends on what “code” is :slightly_smiling_face:
OK, so what’s the terminology for ‘code’, then?
I want to copy the code of a function, make changes in it, and paste it as a new function.
That’s the problem - is code short for machine code?
Ah! Now I get it.
When a function is compiled, the original source code is not stored in the function value.
I’m OK with doing it at compile-time, with a macro of some sort.
What is the overall goal here? To define some functions that are similar?
It’s that tokenizer I was fiddling with, that’s still not working.
So I thought, ‘hey, the only difference is “lexer” vs “lexer-src-pos”, so couldn’t I do a search-and-replace?’
Something like, (define simple-tokenizer (except-with-replacement make-tokenizer "lexer-src-pos" "lexer"))
(define lex/src (lexer-src-pos ...)) ; lexer that returns position tokens
(define (lex in) (position-token-token (lex/src in)) ; lexer that returns tokens
Use lexer-src-pos
to define a lexer lex/src
that returns tokens with positions (in the form of position tokens). Then define a new lexer that calls the lexer lex/src
and simply throws away the source positions.
What is the “in” argument?
The input port.
You can for example try (lex (open-input-string "1+2"))
Huh… It seems to be working now (I’m still getting errors but not from that part, at least.) Thanks.
Great.
This doesn’t seem right. I was expecting ./b
. Is this a bug, or am I misunderstanding what this is supposed to do? > (find-relative-path "/a" "/b")
#<path:../b>
This is Racket 7.4
I think it’s the latter.
The point is to find a path to the second argument, starting from the first.
But the arguments are both complete paths from root. You can’t cd ..
from root.
If path shares no subpath in common with base, path is returned.
Here "/b" is the path and "/a" is the base.
I think you want the more-than-root keyword argument
Ah, so /a
is treated like a path to a directory.
(Right — so I was thinking of /a
and /b
as directories, not as files. Which is why the rule that @soegaard2 mentioned is important.)
Gotcha. I am approaching this thinking of a
and b
as files.
more-than-root
causes the output to be "/b"
when the paths are just root paths, but it not solve my problem. > (find-relative-path "/blah/a" "/blah/b" #:more-than-root? #t)
#<path:../b>
Added context: Given an HTML file, I want to generate a relative path to put in src
or href
attribute relative to that document. The way I’ve been using find-relative-path
has caused it to look in a directory above where a desired file actually is.
From what I’m seeing, I just can’t use a file path as a base
argument.
So this is closer to intended use. > (find-relative-path "/blah" "/blah/b")
#<path:b>
Got it. Thanks all.
I believe that the intention of find-relative-path
is that (simplify-path (build-path a (find-relative-path a b)))
produces b
.
Has anyone used the db package to connect to SQLServer? I’m having difficulty with the connection string and am looking for examples.
Expressions are evaluated at runtime and can be manipulated at compile time, but you can’t mix runtime and compile time together. I think you want a macro like this:
(define-syntax-rule (make-my-tokenizer lexer-type)
(lexer-type ["foo" (do-foo-stuff)] ["bar" ...] ...))
(define my-ordinary-tokenizer
(make-my-tokenizer lexer))
(define my-position-tracking-tokenizer
(make-my-tokenizer lexer-src-pos))
Never mind. I got it to work by creating a DSN (data source name w/config info) using the Windows app ODBC Data Source (64-bit).
That’s what I did when I tested the library against SQL Server (Express).
What’s the difference between promises and futures, exactly? From the docs I’m guessing that promises run concurrently without attempting to run any operations in parallel. Is that right?
Promises are for doing something lazily, they have nothing to do with concurrency or parallelism. Futures are for doing small-but-CPU-intensive operations in parallel.
(minor addendum: promises are also for caching)
There’s also delay/thread
which is concurrent.
Is there the Racket solution for await/async?
@yfangzhe Racket has lightweight threads, you should just use those.
Racket threads are so much nicer imo.
@lister.daniel has joined the channel
OTOH Racket has very powerful control operators.
yes, you can also just use call/cc
to do the equivalent of async/await
@stchang thanks for the graph library
lol
Is this AOC?
Wut, there’s fewest-vertices-path
in the graph library? That’s cheating! lol
Ohhh. It’s just doing the general shortest path. That makes sense. I thought there’s a procedure to find LCA path (which would be weirdly too specific).
Wow! The idea of adding property to the edges and vertices is really cool. That is a really nice way to allow extensions to the algorithms.
Wow wow for the number of algorithms you covered.
@stchang nice job! :clap::clap::clap: