laurent.orseau
2021-7-28 07:57:05

What does “ellipsis saturation” mean?


ryanc
2021-7-28 13:27:04

@notjack You might find do/sequence useful.


shu--hung
2021-7-28 17:57:59

Oops, I don’t think thats a word. I’m trying to refer to this: if (main ...) = (A B C), then right now ((main ...) ...) = ((A B C) (A B C)) instead of ((A A A) (B B B) (C C C)). The pattern variables match the ellipses from the inside instead of from the outside.


massung
2021-7-28 19:14:03

I’m missing a tiny bit of info that’s making something a little confusing for me. I have a struct like so:

(struct foo #:property prop:sequence (lambda (f) (foo->stream f)) #:methods gen:stream [...]) The foo->stream function works fine, and I can use for loops with my foo structs just fine. However, I’m a little confused by the following:

(define xs (foo ...)) (define ys (sequence-map ... xs)) ;; note: this is fine, ys is a sequence (stream? ys) ;=> #f If prop:sequence returns a stream object (and streams are sequences), and sequence-map — I assume — calls stream-map under the hood for stream sequences, then why isn’t ys also stream?


massung
2021-7-28 19:15:26

More importantly, what I want to make sure of is that ys isn’t being eagerly built as a large collection (I want it to be a stream)


sorawee
2021-7-28 19:16:14

Haven’t fully read the whole thing, but I don’t think you need prop:sequence. A stream is already a sequence. E.g.,

(define-struct list-stream (v) #:methods gen:stream [(define (stream-empty? stream) (empty? (list-stream-v stream))) (define (stream-first stream) (first (list-stream-v stream))) (define (stream-rest stream) (list-stream (rest (list-stream-v stream))))]) (sequence? (list-stream 1)) ;=> #t


massung
2021-7-28 19:16:48

w/o the prop:sequence the for loops won’t implicitly work


sorawee
2021-7-28 19:16:58

Ohhh, that’s new to me


sorawee
2021-7-28 19:17:03

Interesting.


massung
2021-7-28 19:17:13

I mean, maybe that’s a bug, but that’s how it is


sorawee
2021-7-28 19:19:06

This seems to work fine for me


sorawee
2021-7-28 19:19:08

(define-struct list-stream (v) #:methods gen:stream [(define (stream-empty? stream) (empty? (list-stream-v stream))) (define (stream-first stream) (first (list-stream-v stream))) (define (stream-rest stream) (list-stream (rest (list-stream-v stream))))]) (for ([x (list-stream '(1 2 3))]) (println x))


massung
2021-7-28 19:19:59

That works for me as well, but my code — which implements streams just fine for stream-map, etc. — does not


massung
2021-7-28 19:20:14

oh wait


massung
2021-7-28 19:20:20

ugh… nvm, im stupid :wink:


massung
2021-7-28 19:20:35

my original question still hold


massung
2021-7-28 19:21:03

I basically have foo and foo-stream, because the data required is different (as opposed to list, which is - itself - a simple stream)


massung
2021-7-28 19:21:12

so foo->stream returns a different type


sorawee
2021-7-28 19:21:13

For sequence-map, the result is not a stream, but it’s still can be lazily built


massung
2021-7-28 19:21:29

I use prop:sequence to return the foo-stream type


massung
2021-7-28 19:22:43

> For sequence-map, the result is not a stream, but it’s still can be lazily built Okay, that’s pretty much what I needed to be sure of. Thanks


sorawee
2021-7-28 19:23:41

As a concrete example: (stream? (in-cycle '(1 2 3))) returns #f, but (in-cycle '(1 2 3)) is an infinite sequence. It can’t be built eagerly! Same for (sequence-map add1 (in-cycle '(1 2 3))).


massung
2021-7-28 19:25:37

Yeah, I was doing things like (define xs (range 10000000)) (define ys (sequence-map add1 xs))


massung
2021-7-28 19:25:43

And making sure memory wasn’t going up


sorawee
2021-7-28 19:25:43

Oh


sorawee
2021-7-28 19:25:50

range is different, because it produces a list, which is eager


sorawee
2021-7-28 19:25:58

You want in-range


massung
2021-7-28 19:26:25

good pro tip. thanks :wink:


notjack
2021-7-28 19:34:25

@ryanc can’t use it outside a for loop :(


notjack
2021-7-28 21:27:08

What sorawee said: both sequences and streams can be lazy. The difference is that streams are expected to expose an iteration API that doesn’t use mutable state.


notjack
2021-7-28 21:28:20

is this for that ordered hash data structure you’re working on?


seanbunderwood
2021-7-28 21:59:52

Meanwhile, over in Java, streams are the ones that are expected to expose a mutable API. :disappointed:


massung
2021-7-28 23:08:05

It’s not an ordered hash. Hash just happened to be a good example of a multiple value sequence.


sorawee
2021-7-29 00:33:30

The spams (I count 6) on the mailing list over the past month mostly associate with the handler “boutinputs” from protonmail. Can we block him/her?

Also, would it be possible to setup a filter? I can’t see any legitimate context for a Swastika symbol to appear in the mailing list.


sorawee
2021-7-29 00:34:25

It also actually looks like a smear campaign.


jmhimara
2021-7-29 02:12:46

Are you referring to the italian posts complaining about pedophiles and such?


samth
2021-7-29 02:34:17

I blocked several people who spammed recently


samth
2021-7-29 02:34:27

I’ll check who sent the most recent one


samth
2021-7-29 02:34:36

But it’s not possible to create a filter


sorawee
2021-7-29 03:17:25

@jmhimara yeah


jmhimara
2021-7-29 03:28:01

I joined the list recently and was taken aback


jesse697
2021-7-29 06:21:21

I just noticed that symbols aren’t a built-in syntax class in syntax/parse. Looks like you can define new syntax classes with define-syntax-class, but as far as I can tell that ultimately relies upon the built-in classes. So if one wanted symbols to be a new syntax class, one would need to add a new built-in class to syntax/parse. Is that right?


sorawee
2021-7-29 06:22:06

Symbol is just (quote a) where a is an id, right?


jesse697
2021-7-29 06:22:44

hmm, let me check if that works


sorawee
2021-7-29 06:24:18

#lang racket (require syntax/parse/define) (define-syntax-parse-rule (foo ({~literal quote} a:id)) (define a 1)) (foo 'abcdef) abcdef ;=> 1


jesse697
2021-7-29 06:27:50

thanks! it’s a bit bulky, so I’ll try to make this more compact with define-syntax-class, but that’s what I was looking for