I am trying to match a whole string, to be an integer number.
My thinking is, that an integer starts with a non zero digit and then goes
on with an arbitrary number of digits (including zero).
I put it in a regexp as follows:
(regexp-match #rx"[1-9]+[0-9]*" (current-input-port))
But this is
Try `regexp-try-match`.
The `regexp-match` function on an input port consumes non-matching
input, which means that it consumes all input if a pattern that starts
"^" doesn't match the beginning of the input.
(This behavior is mentioned in the docs for `regexp-match`, but the
docs have to say so
Hello Racketeers,
I have been playing around with the `math/number-theory` package and I
wanted to use a `for`-loop of Fibonacci numbers. I had to write something
like
(for ([i (in-naturals)])
(define fib (fibonacci i))
...)
So I thought it would be nice to have an
I hope there's a better way, but this works. The adapter submodule is
needed because the normal `stream-cons` is a macro that expands into some
private things that don't have types, and it requires that the rest
expression produce a stream, not just any sequence. Note also, if you
haven't worked
On Sun, Apr 22, 2018 at 10:40 PM, Zelphir Kaltstahl
wrote:
> Ah OK, I understand that additional newline. Since the code matching the
> regex is run before that newline gets in, the newline will be on the
> input port.
>
> In DrRacket I observe the following:
>
> (I
Ah OK, I understand that additional newline. Since the code matching the
regex is run before that newline gets in, the newline will be on the
input port.
In DrRacket I observe the following:
(I remembered that there are negative numbers :D and my regex got a bit
more complicated.)
~~~
Typed Racket is reminding you that `read-line` can produce EOF. If you
handle that (for example, with `(assert something string?)`) then it
works correctly.
Sam
On Sun, Apr 22, 2018 at 4:40 PM, Zelphir Kaltstahl
wrote:
> Ah OK, I understand that additional newline.
> On Apr 22, 2018, at 1:40 PM, Zelphir Kaltstahl
> wrote:
>
> Ah OK, I understand that additional newline. Since the code matching the
> regex is run before that newline gets in, the newline will be on the
> input port.
>
> In DrRacket I observe the following:
>
>
I am sorry, I think I am still misunderstanding it.
When I try:
(regexp-try-match #rx"^[1-9]+[0-9]*$" (current-input-port))
It also results immediately in:
#f
> "^" doesn't match the beginning of the input
Is there something else I should use to start matching from the
beginning of whatever
At Sun, 22 Apr 2018 14:54:26 +0200, Zelphir Kaltstahl wrote:
> I am sorry, I think I am still misunderstanding it.
>
> When I try:
>
> (regexp-try-match #rx"^[1-9]+[0-9]*$" (current-input-port))
>
> It also results immediately in:
>
> #f
Using stdin both for reading an expresion and getting
10 matches
Mail list logo