Hacker News new | ask | show | jobs
by patates 689 days ago
Do you know why the tail is needed? Like, what would be the problem with this:

    fun is_sorted(list):
      match list:
      | []: #true
      | [_]: #true
      | [head, next, ...]:
          head .<= next && is_sorted([next, ...])
2 comments

    ~ $ racket -I rhombus
    Welcome to Racket v8.13 [bc].
    > fun is_sorted(list):
        match list:
        | []: #true
        | [_]: #true
        | [head, next, ...]:
            head .<= next && is_sorted([next, ...])

    ; readline-input:6:19: next: cannot use repetition binding as an expression
    ;   in: next
    ; [,bt for context]

From there I got to "repetition binding" in the docs: https://plt.cs.northwestern.edu/pkg-build/doc/rhombus/Repeti...

From what I can understand, the "..." isn't independent of the previous expression in the list (as I would have expected from e.g. Prolog or Haskell). Instead you are defining a kind of pattern to reuse later, so tail gives a name to the rest of the list (so that it doesn't get associated with next).

Ah, now that makes sense, the three dots need to be assigned to a variable. It's just how they do it is completely new to me. Thank you for finding out!
I wondered this too, let's find out. I am looking all this up as I go, partially as an experiment to find out how easy it is to use Rhombus.

    $ raco pkg install rhombus --auto
which should work if you have some vaguely recent install of racket on your machine and handle the dependencies without prompting.

(I started installing this several hours ago on a slow machine but it's still going.)

It's supposed to take a couple of minutes.

Please file a bug report so this can be tracked down.

https://github.com/racket/rhombus

I'm not going to file a bug report, that's more time than I'm willing to spend on a project I'm not involved in. I will say I'm using Termux 0.118 and Racket 8.13 on kernel 5.10 and Android 14 and am willing to answer questions.
> I'm not going to file a bug report, that's more time than I'm willing to spend on a project I'm not involved in.

In that case, I make it quick - and refrain from any followup questions.

Did you by chance pick the "Minimal Racket" distribution?

If so, your command essentially compiled large parts of Racket and generated the entire set of documentation.

The distribution "Full Racket" is the recommended distribution for most purposes. It comes with everything pre-compiled.

No, but yes.

https://github.com/termux/termux-packages/blob/master/packag...

I just installed the package called `racket` from Termux's upstream, and it seems that they're using racket-minimal for that. Bit of a gotcha, but at least it doesn't seem like there's a bug. Thanks for the tip.

Thanks for the response.

I'll contact the Termux people and ask if the choice of `racket-minimal` was intentional.