Jump to content

Substring/Top and tail: Difference between revisions

→‎{{header|Euphoria}}: Euphoria example added
(Added D version)
(→‎{{header|Euphoria}}: Euphoria example added)
Line 55:
writeln("brooms"[1..$-1]); // strip both first and last characters
}</lang>
 
=={{header|Euphoria}}==
<lang euphoria>
function strip_first(sequence s)
return s[2..$]
end function
 
function strip_last(sequence s)
return s[1..$-1]
end function
 
function strip_both(sequence s)
return s[2..$-1]
end function
 
puts(1, strip_first("knight")) -- strip first character
puts(1, strip_last("write")) -- strip last character
puts(1, strip_both("brooms")) -- strip both first and last characters</lang>
 
=={{header|Icon}} and {{header|Unicon}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.