Strip control codes and extended characters from a string: Difference between revisions

m
simplification for OCaml
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
m (simplification for OCaml)
Line 1,547:
 
<syntaxhighlight lang="ocaml">let is_control_code c =
letc d< ='\032' int_of_char|| c in= '\127'
 
d < 32 || d = 127
let is_extended_char c =
dc > '\127'
let d = int_of_char c in
 
d > 127
let strip f str =
let len = String.length str in
Line 1,559 ⟶ 1,557:
let rec aux i j =
if i >= len
then Bytes.to_string (Bytes.subsub_string res 0 j)
else if f str.[i]
then aux (succ i) j
Line 1,568 ⟶ 1,566:
in
aux 0 0
 
let () =
Random.self_init ();
Line 1,577 ⟶ 1,575:
in
print_endline (strip is_control_code s);
print_endline (strip (fun c -> (is_control_code c) || (is_extended_char c)) s);</syntaxhighlight>
;;</syntaxhighlight>
 
=={{header|Pascal}}==
559

edits