Skip to content

Instantly share code, notes, and snippets.

@sshine
Last active August 27, 2018 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshine/ef8c7c2e3c4f3f6c702a88b6cadf7f4a to your computer and use it in GitHub Desktop.
Save sshine/ef8c7c2e3c4f3f6c702a88b6cadf7f4a to your computer and use it in GitHub Desktop.
open Base
let acronym s =
Buffer.contents
(String.foldi s
~init:(Buffer.create 4)
~f:(fun i buf c -> if c = ' ' then Buffer.add_char buf (String.get s (i+1)) else () ; buf))
(* ^^^^^^^ *)
File "acronym.ml", line 8, characters 29-30:
Error: This expression has type String.elt
but an expression was expected of type int
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment