Skip to content
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

exercises: some examples should be improved #313

Open
ee7 opened this issue Sep 8, 2023 · 0 comments
Open

exercises: some examples should be improved #313

ee7 opened this issue Sep 8, 2023 · 0 comments
Assignees

Comments

@ee7
Copy link
Member

ee7 commented Sep 8, 2023

I've already got a local branch for this. I'll get around to creating the PRs.

@ee7 ee7 self-assigned this Sep 8, 2023
ee7 added a commit that referenced this issue Sep 14, 2023
Zig 0.11.0 added new for loop syntax [1]. Prefer to loop over a range,
which avoids some variables.

For more discussion, see Loris' blog post [2].

[1] https://ziglang.org/download/0.11.0/release-notes.html#Multi-Object-For-Loops
[2] https://kristoff.it/blog/zig-multi-sequence-for-loops/

Refs: #313
@ee7 ee7 changed the title exercises: some examples should be refactored exercises: some examples should be improved Sep 15, 2023
ee7 added a commit that referenced this issue Sep 19, 2023
Use errdefer where we later use toOwnedSlice.

Refs: #313
ee7 added a commit that referenced this issue Sep 19, 2023
std.math.log10 accepted integers, but performed a round-trip float
conversion. It could thereby produce incorrect results for a large
integer near a power of 10. The first such example is

    std.math.log10(999_999_999_999_998)

which produces 15 instead of 14.

Zig 0.11.0 added math.log10_int [1], which doesn't have this problem.
Use that instead.

For more background, see the commit that added this exercise [2].

[1] ziglang/zig@311d50f9dc96
[2] 0c82fec, 2023-02-21, "exercises: add armstrong-numbers"

Refs: #313
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant