Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Laurent
I don't know what the exact specs are, but what should be the return values for '(a a a b b c) and '(a a b b b c) ? (I can't test right now but I suspect the match approach might miss one) On Wed, Dec 4, 2019, 23:56 Matthew Butterick wrote: > > On Dec 4, 2019, at 3:26 PM, 'Joel Dueck' via

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick
> On Dec 4, 2019, at 3:26 PM, 'Joel Dueck' via Racket Users > wrote: > > I like the trick of using list* to match _ on any number of trailing > elements. The grammar given in the docs doesn't seem to include it; I'm > curious by what rule is it "allowed" as a pattern? It's a synonym for the

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread 'Joel Dueck' via Racket Users
I feel stupid too! I like the trick of using list* to match _ on any number of trailing elements. The grammar given in the docs doesn't seem to include it; I'm curious by what rule is it "allowed" as a pattern? On Wednesday, December 4, 2019 at 5:02:48 PM UTC-6, Sorawee Porncharoenwase wrote:

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Sorawee Porncharoenwase
This is super cool indeed. Now I feel stupid. On Wed, Dec 4, 2019 at 2:56 PM Matthew Butterick wrote: > > On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users < > racket-users@googlegroups.com> wrote: > > So it seems easy to match "*at least *N identical elements". > But is there a method

Re: [racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread Matthew Butterick
> On Dec 4, 2019, at 2:39 PM, 'Joel Dueck' via Racket Users > wrote: > > So it seems easy to match "at least N identical elements". > But is there a method for matching "no more than N identical elements"? ? #lang racket (require rackunit) (define (super-cool? lst) (match lst [(and

[racket-users] Limiting consecutive identical elements with match

2019-12-04 Thread 'Joel Dueck' via Racket Users
(This is related to the problem for this year’s Advent of Code day 4, so...SPOILERS.) (I did solve both parts of today's problem, so this is more for my own edification.) The problem involves finding lists of numbers, one of the criteria for which is that the list has at least two consecutive

[racket-users] Scribble output without navigation

2019-12-04 Thread 'Reuben Thomas' via Racket Users
How can I get scribble/base to output HTML without the navigation elements? I just want a plain HTML page, similar to the look of the LaTeX output. I can of course extract the "main" div from the standard output, but that seems to be somewhat shutting the stable door after the horse has bolted.

Re: [racket-users] Vector length and indices contracts

2019-12-04 Thread Matthew Flatt
At Wed, 4 Dec 2019 22:24:10 +0100, Dominik Pantůček wrote: > What about all the vector-ref, -set! and basically all indices > contracts? That should probably be the same. I'm less enthusiastic about that change. It turns out that a non-fixnum argument won't work for `vector-ref`, but the stronger

Re: [racket-users] Vector length and indices contracts

2019-12-04 Thread Dominik Pantůček
On 04. 12. 19 20:21, Matthew Flatt wrote: > I think it makes sense to refine the contract to guarantee a fixnum > result for `vector-length`. > > This fact is currently documented in `unsafe-vetcor-length`, because > that's the layer where it has seemed sensible to talk about fixnums in > the

Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
On Wed, 4 Dec 2019 at 13:45, Matthew Flatt wrote: > I'm not sure I follow completely, but I think the problem is the > compound-paragraph parsing that is triggered by the lack of space > between the two `para` calls: > Exactly right. I tried to find out if this is documented. I couldn't find

Re: [racket-users] Vector lenght and indices contracts

2019-12-04 Thread Matthew Flatt
I think it makes sense to refine the contract to guarantee a fixnum result for `vector-length`. This fact is currently documented in `unsafe-vetcor-length`, because that's the layer where it has seemed sensible to talk about fixnums in the past, but that's not where anyone would think to look.

Re: [racket-users] Vector lenght and indices contracts

2019-12-04 Thread George Neuner
On 12/4/2019 11:03 AM, Dominik Pantůček wrote looking at vector-length[1] documentation, it returns (exact-nonnegative-integer?). However, as far as I can tell, it returns (fixnum?). Also for subsequent contracts in the vector's documentation all indices are assumed to be

Re: [racket-users] How to use dates (especially gregor) with Typed Racket?

2019-12-04 Thread Jon Zeppieri
On Tue, Dec 3, 2019 at 8:55 PM Ben Greenman wrote: > > The error is because gregor/time doesn't export a struct. But > nevermind that, because you're probably best off with an opaque type: > > ``` > #lang typed/racket > > (require/typed gregor/time > [#:opaque Time time?] > [time (->*

[racket-users] Vector lenght and indices contracts

2019-12-04 Thread Dominik Pantůček
Hello, looking at vector-length[1] documentation, it returns (exact-nonnegative-integer?). However, as far as I can tell, it returns (fixnum?). Also for subsequent contracts in the vector's documentation all indices are assumed to be (exact-nonnegative-integer?) but usually it is impossible on

Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread Matthew Flatt
I'm not sure I follow completely, but I think the problem is the compound-paragraph parsing that is triggered by the lack of space between the two `para` calls: @foo{@para[#:style "foo"]{Bar.} @para{Bar.}} If you change it to @foo{@para[#:style "foo"]{Bar.} @para{Bar.}} then the

Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
After a few more experiments, I find that I can't work out another problem I was having: nested elements (which is not legal HTML). This occurs when I put a style on a @para; for example, a small change to the example code that Matthew kindly provided: #lang scribble/base @(require

Re: [racket-users] Scribble: how to wrap a flow in a style?

2019-12-04 Thread 'Reuben Thomas' via Racket Users
On Mon, 2 Dec 2019 at 23:06, Matthew Flatt wrote: > > Ah, it looks like `alt-tag` is the one that works, instead of > `body-id`. (I'll fix the docs.) > Thanks for this. I had come across alt-tag before, but I didn't think of it here; it didn't occur to me that an HTML-specific solution would