You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently developing functions that make heavy use of strings and the core::strings module. In this process I have been unable to use the postfix apply operator almost at all due to argument order. I would love if either the order got changed to make the string worked on the last argument or to make a set of postfix apply friendly versions.
I believe it would make string heavy code more easily readable and easier to refactor. As an example here is the current version of str_replace and a version using pipes on the assumption that the first argument of all string functions were moved to the end of the argument list:
# Current implementationfnstr_replace(s: String, pattern: String, replacement: String) ->String=ifpattern==""thenselseifstr_contains(s, pattern)
thenifstr_slice(s, 0, str_length(pattern)) ==patternthenstr_append(replacement, str_replace(str_slice(s, str_length(pattern), str_length(s)), pattern, replacement))
elsestr_append(str_slice(s, 0, 1), str_replace(str_slice(s, 1, str_length(s)), pattern, replacement))
elses# same implementation but with arguments moved and using pipes (also used a hypothetical prepend function instead of append)fnstr_replace(pattern: String, replacement: String, s: String) ->String=ifpattern==""thenselseifstr_contains(s, pattern)
thenifstr_slice(s, 0, str_length(pattern)) ==patternthen (s|>str_slice(str_length(pattern), str_length(s)) |>str_replace(pattern, replacement) |>str_prepend(replacement))
else (s|>str_slice( 1, str_length(s)) |>str_replace(pattern, replacement) |>str_prepend(str_slice(s, 0, 1)))
elses
The text was updated successfully, but these errors were encountered:
I'm currently developing functions that make heavy use of strings and the
core::strings
module. In this process I have been unable to use the postfix apply operator almost at all due to argument order. I would love if either the order got changed to make the string worked on the last argument or to make a set of postfix apply friendly versions.I believe it would make string heavy code more easily readable and easier to refactor. As an example here is the current version of
str_replace
and a version using pipes on the assumption that the first argument of all string functions were moved to the end of the argument list:The text was updated successfully, but these errors were encountered: