File: sample.ml

package info (click to toggle)
ocaml-estring 20130822-5
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 152 kB
  • ctags: 81
  • sloc: ml: 347; makefile: 58; sh: 15
file content (24 lines) | stat: -rw-r--r-- 542 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(*
 * sample.ml
 * ---------
 * Copyright : (c) 2009, Jeremie Dimino <jeremie@dimino.org>
 * Licence   : BSD3
 *
 * This file is a part of estring.
 *)

open Printf

(* [x] is a list of characters defined in a convenient way: *)
let x = l"Hello, world!"

(* Simple function on list of characters: *)
let replace patt repl l =
  List.map (fun ch -> if ch = patt then repl else ch) l

let y = replace 'o' 'i' x

let output_char_list oc l = List.iter (output_char oc) l

let _ =
  printf "x = %a\ny = %a\n" output_char_list x output_char_list y