Substring/Top and tail: Difference between revisions
Content added Content deleted
(Added D version) |
(→{{header|Euphoria}}: Euphoria example added) |
||
Line 55: | Line 55: | ||
writeln("brooms"[1..$-1]); // strip both first and last characters |
writeln("brooms"[1..$-1]); // strip both first and last characters |
||
}</lang> |
}</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}}== |
=={{header|Icon}} and {{header|Unicon}}== |