[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: getusershell: Split file by lines instead of spaces.
From: |
Collin Funk |
Subject: |
Re: getusershell: Split file by lines instead of spaces. |
Date: |
Tue, 21 May 2024 18:14:01 -0700 |
User-agent: |
Mozilla Thunderbird |
Hi Bruno,
On 5/21/24 5:43 PM, Bruno Haible wrote:
> The new patch is good. OK to push.
Done, thanks.
>> Interesting way to think about it, thanks. Do you have a strong math
>> background? It has been a while since I looked at that interval
>> notation.
>
> Oh, I learned the interval notation at school. It's really nothing fancy.
I remember seeing it in school but I don't use it enough. It was quick
to relearn using set builder notation [1]. So feel free to use it in
any future explanations. :)
> The problem with the [start,end] convention is that it cannot
> represent an empty array slice. Therefore, when you are dealing
> with a problem in which an empty array slice is a valid special
> case, [start,end] is the wrong representation.
>
> Try to formulate a non-trivial algorithm, such as bubble sort
> or searching an item in a sorted array using binary-search.
> If you do it ad-hoc with cursors or some such, chances a high
> that you will introduce off-by-one mistakes or endless loops.
> Try it with the [start,end) convention, and you will succeed.
Good point. I'd like to think I would use [start,end) when writing
those. But better to build good habits for even simple algorithms like
this. I'll keep that in mind for the future.
I made a mess out of my /etc/shells (lots of blank lines, trailing
comments, trailing spaces, etc) and ran with Valgrind before sending
that patch. Time to clean that up now.
Collin
[1]
https://en.wikipedia.org/wiki/Interval_(mathematics)#Including_or_excluding_endpoints
- Re: [PATCH] getusershell: Work around musl bugs., (continued)
- Re: [PATCH] getusershell: Work around musl bugs., Bruno Haible, 2024/05/19
- Re: [PATCH] getusershell: Work around musl bugs., Collin Funk, 2024/05/19
- Re: [PATCH] getusershell: Work around musl bugs., Bruno Haible, 2024/05/19
- Re: [PATCH] getusershell: Work around musl bugs., Collin Funk, 2024/05/19
- getusershell: Split file by lines instead of spaces., Collin Funk, 2024/05/20
- Re: getusershell: Split file by lines instead of spaces., Bruno Haible, 2024/05/20
- Re: getusershell: Split file by lines instead of spaces., Collin Funk, 2024/05/21
- Re: getusershell: Split file by lines instead of spaces., Bruno Haible, 2024/05/21
- Re: getusershell: Split file by lines instead of spaces., Collin Funk, 2024/05/21
- Re: getusershell: Split file by lines instead of spaces., Bruno Haible, 2024/05/21
- Re: getusershell: Split file by lines instead of spaces.,
Collin Funk <=
- Re: [PATCH] getusershell: Work around musl bugs., Bruno Haible, 2024/05/20
- Re: [PATCH] getusershell: Work around musl bugs., Collin Funk, 2024/05/20
- Re: [PATCH] getusershell: Work around musl bugs., Bruno Haible, 2024/05/20