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

Approaches for reverse-string #657

Merged
merged 10 commits into from
Jan 21, 2024
Merged

Conversation

glennj
Copy link
Contributor

@glennj glennj commented Jan 21, 2024

Plus a performance article.

@glennj glennj requested a review from a team January 21, 2024 00:14
- `< <(printf "%s" "%string)` is redirecting (`<`) a [process substitution][process-subst] (`<(...)`).
We could use a [here-string][here-string] (`<<< "$string"`), but that appends a newline.
Using `printf` like that redirects the string exactly as it is.
- `IFS= read -d "" -r -n 1 char` OK there's a lot going on there with this [`read` command][read]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `IFS= read -d "" -r -n 1 char` OK there's a lot going on there with this [`read` command][read]:
- `IFS= read -d "" -r -n 1 char` there's a lot going on there with this [`read` command][read]:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll use

- `IFS= read -d "" -r -n 1 char`: There's a lot going on there with this [`read` command][read].

@@ -0,0 +1,5 @@
```bash
while IFS= read -d "" -r -n 1 char; do
echo "$char"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "$char"
echo -n "$char"

@glennj glennj requested a review from IsaacG January 21, 2024 17:41
@glennj glennj merged commit c5d6b5f into exercism:main Jan 21, 2024
2 checks passed
@glennj glennj deleted the approach-reverse-string branch January 22, 2024 17:14
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

Successfully merging this pull request may close these issues.

2 participants