@sarna.dev has joined the channel
Hi, I wanted to know if it is possible to create gRPC APIs for streaming in Racket. If not, does anyone know how I could help with creating such a framework or library for Racket. I think it would be really nice.
Hmm, I haven’t seen any streaming APIs in Racket yet. (The Overscan package seems to deal with streaming media, but that’s probably not what you’re looking for.)
What is the correct way to have “tuples” in typed racket?
Use structs? Unsure what your requirements for tuples are.
I have a function returning multiple values and thought that would be a good ide to return as a tuple. ITMT I’ve found I can have heterogeneous list, like (List Integer Integer Char String)
you can just use values
if you don’t need to pass them around as a whole
@soegaard2 I have tried a little bit urlang. Is it not possible to use printf, format, round, floor, string-append etc within urlang block for defined procedures, even with urlang/extra ? I found that causes unbound errors as I made following script: jarmo$ cat funcs.rkt
#lang racket
(require urlang urlang/extra)
(require racket/date)
(current-urlang-run? #t)
(current-urlang-echo? #t)
(current-urlang-console.log-module-level-expr? #t)
(displayln
(urlang
(urmodule funcs
(define (ctof cdeg) (+ 32 (* 1.8 cdeg)))
(define (ftoc fdeg) (/ (- fdeg 32) 1.8))
(define (bmi wkg lm) (/ wkg lm lm))
"Convert -5 C to F" (ctof -5)
"Convert 23 F to C" (ftoc 23)
"BMI for body weight 85 kg, length 1.85 m = " (bmi 85 1.85)
)))
It has made this JS which I have manually completed for console outs: jarmo$ cat funcs.js
"use strict";
function ctof(cdeg){return (32+(1.8*cdeg));};
function ftoc(fdeg){return ((fdeg-32)/1.8);};
function bmi(wkg,lm){return (wkg/lm/lm);};
console.log("Convert", -5, "C to F", ctof(-5));
console.log("Convert", 23, "F to C", ftoc(23));
console.log("BMI for body weight 85 kg, length 1.85 m = ",
(bmi(85,1.85).toFixed(2)));
That was run within node: jarmo$ node funcs.js
Convert -5 C to F 23
Convert 23 F to C -5
BMI for body weight 85 kg, length 1.85 m = 24.84
@pihentagy (define (first a) (car a))
(define (second lista) (car (cdr lista)))
(first '(1 2 3 4))
(second '(1 2 3 4))
(printf "This is not second:\n")
(cdr '(1 2 3 4))
result: 1
2
This is not second:
'(2 3 4)
>
so let’s say that I have a sequence that is 3 parallel values, and a sequence that is a single value. how can I turn this into a sequence with four parallel values?
@hazel I think, you are looking for in-cycle
no since I don’t want the resulting sequence to be infinite
like if I have a sequence that’s (1 2 3) -> (4 5 6) -> (7 8 9) -> end
, and a sequence that’s #f -> #f -> #f -> end
then I want a sequence that’s (1 2 3 #f) -> (4 5 6 #f) -> (7 8 9 #f) -> end
so kind of like in-parallel
, but flattened
> (sequence-for-each (lambda (x y) (printf "(~a ~a) " x y)) (in-parallel "hello" "slick"))
(h s) (e l) (l i) (l c) (o k)
so like this but with multiple elements in the first stream
Hi, I have a module defining a datastructure that can be parametrized by two module-level variables (top level define
). How do I make it possible to import several variants by name (i.e. differing only by the two top-level vars)? Can I use normal parameters and submodules, or do I need to generate submodules at compile-time with syntax parameters?
The goal is that what you would write in untyped Racket should work in Typed Racket too
This is the standard use case for units
However, you might also consider just using lambda
@hazel you should probably just write that combinator yourself
@hazel Alternatively, consider grouping the values into structs, so you’d have a sequence of structs instead of a multi-value sequence. Then you can use sequence-map
to combine the two sequences.
I believe there’s a library with an in-mapped
operation which does something like sequence-map
but in a way that gets inlined in a for
loop.
It can’t be used outside of a for
loop though, so it doesn’t take the place of sequence-map
.