Jump to content

Brace expansion using ranges: Difference between revisions

m
Line 870:
=={{header|Julia}}==
Julia currently does not handle certain trigraphs in strings correctly, such as 🌶, so that test is omitted.
<lang julia>prefixzerospadzeros(str) = (len = length(str)) > 1 && str[1] == '0' ? length(str)len : 0
 
function ranged(str)
Line 880:
if '0' <= rang[1][1] <= '9' || rang[1][1] == '-'
x, y = parse(Int, rang[1]), parse(Int, rang[2])
pad = max(prefixzerospadzeros(rang[1]), prefixzerospadzeros(rang[2]))
return [string(x, pad=pad) for x in range(x, step=(x < y) ? delta : -delta, stop=y)]
else
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.