Making sequences with missing values

27 views
Skip to first unread message

Raoul Schorer

unread,
Mar 7, 2021, 5:23:49 AM3/7/21
to Racket Users

Hi,

I'd like missing values (NAs) a la R in sequences, such as a `bit-vector` with a 3rd NA value (therefore taking 2 bits/element and not 1). I'd like that for integers, flonums, etc. too. I'm trying to make a (struct seq/na (mask data)) with prop:sequence, separating the NA mask from the sequence elements and design `for` forms to iterate on those. Trying to follow the prop:sequence and for/fold/derived examples, I tried:

(struct bit-vector/na (missing bits)
  #:property prop:sequence
  (λ (i j) (in-parallel (bit-vector/na-missing i) (bit-vector/na-bits j))))

but that failed with:

../../../../usr/share/racket/collects/racket/private/for.rkt:488:5: sequence-property-guard: contract violation
  expected: (procedure-arity-includes/c 1)
  given: #<procedure:.../in-memoriam.rkt:34:2>

I understand the sequence interface is designed to consume a single element per iteration, but is there a way to achieve what I'd like?

Thanks!
Raoul
Reply all
Reply to author
Forward
0 new messages