-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debug code left in regex example #26
Comments
Thanks for reporting. I think you are referring to the example
Yes, the statement "when true: discard" was intended to avoid all the output, because we try to compare the performance of various parsing strategies. With actual output, that would be dominated by the relatively slow output operation. Maybe I should better have defined a const named Debug, and used that const to suppress output. I think some of the other examples do that. I may adapt this example next time when I apply again some tiny grammar fixes. I think GPT-4 may find some more. And congratulations that you have managed to read the book so far. Have you been able to follow the explanations and understand them? Best regards, Stefan Salewski |
Hello,
Thank you for replying. I think the explanations in the book are quite clear and have had no problem understanding them. I appreciate that your code is easy to copy and paste, and not lose indentations. I have been programming professionally since 1966 (scientific programming was all FORTRAN in those days), but now just program for enjoyment in languages that I like, such as nim, scheme and OCAML.
You might consider expanding your section on sequtils to include additional functional functions such as foldl and foldr and how to "pipeline" functions: data |> function1 >| function2 >| function 3
Regards,Doug Telford
On Monday, June 19, 2023 at 12:04:33 AM MDT, StefanSalewski ***@***.***> wrote:
Thanks for reporting. I think you are referring to the example
import regex
from std/strutils import repeat
const
FileName = "csvdata.txt"
P = """([^,]+)"""
r = re(repeat(P & ',', 5) & P)
proc main =
var m: RegexMatch
for l in Filename.lines:
if l[0] != '#': # skip first two and all other comment lines
if match(l, r, m):
when true: # debug
discard
else:
for i in 0 .. 5:
stdout.write(m.group(i, l))
stdout.write(' ')
echo ""
else:
assert false
main()
Yes, the statement "when true: discard" was intended to avoid all the output, because we try to compare the performance of various parsing strategies. With actual output, that would be dominated by the relatively slow output operation. Maybe I should better have defined a const named Debug, and used that const to suppress output. I think some of the other examples do that. I may adapt this example next time when I apply again some tiny grammar fixes. I think GPT-4 may find some more.
And congratulations that you have managed to read the book so far. Have you been able to follow the explanations and understand them?
Best regards,
Stefan Salewski
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
In part VI, process execution, parsing data files(in parallel), using regular expressions:
the code has
if match(l,r,m):
when true: #debug
discard
Maybe this was intended to bypass the large amount of output. Maybe writing it to a file would be better.
The text was updated successfully, but these errors were encountered: