What new feature should Elvish have?
Sometimes, I want each to do something different if it sees no inputs at all, as in each $fn [] or put | each $fn. I suggest an optional argument named else, or perhaps if-none, for this.
To make the proposal clear, here is an elvish implementation.
fn each {|&else=$nil f @inputs|
if $else {
var none = $true
builtin:each {|item| set none = $false; $f $item } $@inputs
if $none { $else }
} else {
builtin:each $f $@inputs
} }
Oh, I almost forgot (since I hardly ever use it): Do the same for for.
Output of "elvish -version"
0.21.0-dev.0.20240809001233-bc247bb5e17c-dirty
Code of Conduct
What new feature should Elvish have?
Sometimes, I want
eachto do something different if it sees no inputs at all, as ineach $fn []orput | each $fn. I suggest an optional argument namedelse, or perhapsif-none, for this.To make the proposal clear, here is an elvish implementation.
Oh, I almost forgot (since I hardly ever use it): Do the same for
for.Output of "elvish -version"
0.21.0-dev.0.20240809001233-bc247bb5e17c-dirty
Code of Conduct