Programming-Idioms

Implementation
Lisp

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Implementation edit is for fixing errors and enhancing with metadata.

Instead of changing the code of the snippet, consider creating another Lisp implementation.

Other implementations
String t = s.substring(0,5);
var t = s.substring(0,5);
t = s[:5]
var t = s.substring(0, 5);
$t = substr($s, 0, 5);
$t = mb_substr($s, 0, 5, 'UTF-8');
#include <stdlib.h>
#include <string.h>
char *t=(char *)calloc(6,sizeof(char));
strncpy(t,s,5);
string t = s[0..5];
_t := Copy(_s, 1, 5);
t :: String
t = take 5 s
import qualified Data.Text as T
t :: T.Text
t = T.take 5 s
t = s[0, 5]
# OR
t = s.slice(0, 5)
t = s.slice(0...5)
t = String.slice(s, 0, 5)
t := string([]rune(s)[:5])
[A, B, C, D, E | _] = S,
T = [A, B, C, D, E].
T = string:slice(S, 1, 5).
t = s:sub(5)
T : String := S (1 .. 5);
string t = s.Substring(0, 5);
auto t = s.substr(0, 5);
val s = "somestring"
val t = s.take(5)
(take 5 s)
 character(len=5) :: t
 t = s(1:5)
val t = s.take(5)
IDENTIFICATION DIVISION.
PROGRAM-ID. prefix 5.
PROCEDURE DIVISION.
    MOVE s(1:5) TO t 	
STOP RUN.
let t = s.char_indices().nth(5).map_or(s, |(i, _)| &s[..i]);