I’m attempting to use https://docs.racket-lang.org/sql/index.html?q=with#%28part._sql-syntax%29 to do some SQL. For the life of me, I can’t work out how to do select x union ...
I’m attempting to do a recursive query (similar to https://sqlite.org/lang_with.html).
The issue I get is the with
form and most other forms expect a select/update/...
at the top level.
The grammar says that union
/should/ work as a table expr, but even with something like (sql (select a #:from (union (select (values 1)) (select x #:from cnt) #:all)))
Haven’t tried sql
for a while, but according to the grammar, you need something like (union ...)
.
I get "SELECT a FROM (SELECT (VALUES (1)) UNION SELECT x FROM cnt)"
which removes the ALL
Yeah but it doesn’t accept it in the top level.
Ah.
So (sql (union ...))
isn’t accepted in the grammar.
I don’t believe so. It maps pretty close to how you would write sql, and you wouldn’t have a bare union in sql, right?
I thought it would translate it to SELECT * FROM X UNION ...
If an example would help, then I bet Ryan has some tests in the sql repo on Github.
There’s a few - but they don’t cover it. I think I’ll read through the code in more depth.
Given this stepper–3–3 function, how can I assign the two values prouced by stepper–3–3 to variables?
(match-define (cons a b) (stepper-3-3 4 7))
or:
(define result-pair (stepper-3-3 4 7))
(define a (car result-pair))
(define b (cdr result-pair))
if you don’t want to use match-define
for any reason
OK the ALL
thing looks like a bug. I’m no closer to understanding the original question though. I’ve opened a github issue and a PR to fix the bug.
minimal racket doesn’t include the drracket ide right ?
right!
the cs binary is hugee. i feel bad for making my users download racket for modding and stuff lol…
Everyone should have Racket installed by default!
#lang racket/base
(println "hello world")
raco demod hello_world.rkt
linkl-exports: contract violation
expected: linkl?
given: #<linklet>
in: the 1st argument of
(-> linkl? (listof symbol?))
contract from:
<pkgs>/zo-lib/compiler/zo-structs.rkt
blaming: <pkgs>/compiler-lib/compiler/demodularizer/name.rkt
(assuming the contract is correct)
at: <pkgs>/zo-lib/compiler/zo-structs.rkt:61.21
context...:
C:\Program Files\Racket\collects\racket\contract\private\blame.rkt:347:0: raise-blame-error
C:\Program Files\Racket\collects\racket\contract\private\arrow-val-first.rkt:486:18
C:\Program Files\Racket\share\pkgs\compiler-lib\compiler\demodularizer\name.rkt:9:0: select-names
C:\Program Files\Racket\share\pkgs\compiler-lib\compiler\demodularizer\main.rkt:22:0: demodularize
body of "C:\Program Files\Racket\share\pkgs\compiler-lib\compiler\demodularizer\batch.rkt"
C:\Program Files\Racket\collects\raco\raco.rkt:41:0
body of "C:\Program Files\Racket\collects\raco\main.rkt"
playing around with reducing size of some utility binaries and demod is not working on racket cs(latest snapshot), or am I using demod wrong?
I’m coding a chess engine in Racket, so speed is of the utmost importance. Would you expect a function like the one below to be inlined, or should I use a macro? (define (is-king? piece)
(= (bitwise-and piece piece-type-bits) king-bits))
oohhh
Thanks :) I started coding this in Julia, but as nice as Julia is for super mathy stuff, as the code grew more and more complicated, I grew more and more dissatisfied :) I’m not sure if Racket will be fast enough for the engine to beat me, but it’ll be fun trying.
No, I think this is a bug, but @mflatt can confirm.
I forgot about raco demod
. It can’t work in its present form for CS, because it is based on reading and rewriting bytecode.
In the specific case above, it does appear that it was inlined. At least there is no difference in speed between define
and define-inline
ahh, so its going to be deprecated for the meantime?
I think it will have to be declared BC-only, at least.
Longer term, I can imagine making it work in combination with compilation to machine-independent mode (as used by the distribution build process), and then recompiling demodularized form to machine code.
Are unsafe vectors still boxed in Racket? I’m wondering if I should just use bytes
since my data will fit in a byte.
Each element of a vector, unsafe or otherwise, is pointer-sized
a vector of bytes will get rid of the indirection because a byte is just a fixnum and fixnums are immediate, but each element will still be pointer-sized so you’ll use something like 8x the space that a byte string would use
@notjack space isn’t a concern for this particular task. If I’m understanding you correctly, if I use (unsafe-vector-set! vec pos #xff)
then the element at position pos will be a pointer sized version of #xff
- is that right? i.e. immediate ?
oh, sorry, re-read your response, yes that does seem to be the case
I guess it comes down to the UI for byte strings vs. vectors since the space isn’t a factor.
For this to be performant, I need to minimize allocations, so there will only be one board state (or maybe one per core later), not one per node in the tree.