Talk:Brace expansion using ranges: Difference between revisions
(5 intermediate revisions by 2 users not shown) | |||
Line 15:
: Perhaps zsh is just not a sufficiently well-defined or consistently implemented target for such a task ?
: Do you know of an arguably canonical implementation of zsh (or some other widely used shell), with well-defined and consistent enumeration rules which we could formally summarize and illustrate here ? [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 18:07, 28 September 2021 (UTC)
: PS I am slow at the best of times, but I still haven't quite understood the macOS zsh {1..6..-2} -> [5,3,1] logic, which I hadn't noticed before ... : [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 18:12, 28 September 2021 (UTC)
: Ah, I see. Starting at one, with intervals of 2, and the whole sequence reversed. [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 18:15, 28 September 2021 (UTC)
::I have added F# based on this discussion, and see that Python has been added using the other possible meaning of flip. No other solutions currently have examples where the meaning of flip is ambiguous. The task description needs updating to: disambiguate flip; include appropriate examples of flipped ranges and a warning added that the task description has changed and solutions may need modifying.--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 13:55, 6 October 2021 (UTC)
:::Thanks – that's very helpful.
:::What's the best tag or other method for drawing attention to an additional test,
:::and warning that modifications may be needed ?
:::[[User:Hout|Hout]] ([[User talk:Hout|talk]]) 20:25, 6 October 2021 (UTC)
::::Perhaps see Dijkstra's algorithm.--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 16:10, 7 October 2021 (UTC)
|
Latest revision as of 16:10, 7 October 2021
Out of curiosity – stepped Alpha seen working in the (unix shell) wild ?
There is a reference to stepped alpha expansions in the increment
section of the reference to which I linked in the task description (https://wiki.bash-hackers.org/syntax/expansion/brace#increment) (referred to without elaboration as an 'interesting feature').
The only reason that haven't implemented it myself (in the current draft of the JS reference implementation) is that it didn't match what I was seeing (macOS Catalina) either in the default zsh command line or in a script with the preamble #!/bin/bash
, neither of which expand {a..z..3}
to anything other than itself.
I don't think that's a good reason to discourage implementing stepped alpha brace ranges here – they seem a good idea, and we do have that reference – but I wondered (idly) if anyone has actually seen stepped alpha expansions work in the wild (where wild is defined as a shell prompt or shell script). Hout (talk) 17:57, 26 August 2020 (UTC)
- Ah. Got it. It's because the macOS Catalina distribution of Bash turns out to be 3.2, rather than 4. Hout (talk) 18:06, 26 August 2020 (UTC)
Flippin' 'eck
What is the behaviour of echo {1..6..-2} using zsh shell on macOS Catalina? Using Linux bash 5.1 it is 1 3 5. Should flipped be 5 3 1 or 6 4 2? It is bad enough when task descriptions require one to debug Python to make sense of it but zsh shell on macOS Catalina, come on.--Nigel Galloway (talk) 14:31, 27 September 2021 (UTC)
- Good point. On zsh 5.8 (macOs – x86_64-apple-darwin20.0), the expansion of {1..6..-2} turns out to be [5,3,1] ...
- Perhaps zsh is just not a sufficiently well-defined or consistently implemented target for such a task ?
- Do you know of an arguably canonical implementation of zsh (or some other widely used shell), with well-defined and consistent enumeration rules which we could formally summarize and illustrate here ? Hout (talk) 18:07, 28 September 2021 (UTC)
- PS I am slow at the best of times, but I still haven't quite understood the macOS zsh {1..6..-2} -> [5,3,1] logic, which I hadn't noticed before ... : Hout (talk) 18:12, 28 September 2021 (UTC)
- Ah, I see. Starting at one, with intervals of 2, and the whole sequence reversed. Hout (talk) 18:15, 28 September 2021 (UTC)
- I have added F# based on this discussion, and see that Python has been added using the other possible meaning of flip. No other solutions currently have examples where the meaning of flip is ambiguous. The task description needs updating to: disambiguate flip; include appropriate examples of flipped ranges and a warning added that the task description has changed and solutions may need modifying.--Nigel Galloway (talk) 13:55, 6 October 2021 (UTC)
- Thanks – that's very helpful.
- What's the best tag or other method for drawing attention to an additional test,
- and warning that modifications may be needed ?
- Hout (talk) 20:25, 6 October 2021 (UTC)
- Perhaps see Dijkstra's algorithm.--Nigel Galloway (talk) 16:10, 7 October 2021 (UTC)
- I have added F# based on this discussion, and see that Python has been added using the other possible meaning of flip. No other solutions currently have examples where the meaning of flip is ambiguous. The task description needs updating to: disambiguate flip; include appropriate examples of flipped ranges and a warning added that the task description has changed and solutions may need modifying.--Nigel Galloway (talk) 13:55, 6 October 2021 (UTC)