all AI news
Format strings in OCaml
Feb. 25, 2024, 2:34 a.m. | Yawar Amin
DEV Community dev.to
OCAML doesn't have string interpolation, but it does have C-style format strings (but type-safe). Here's an example:
let hello name = Printf.printf "Hello, %s!\n" name
(* Can be written as: let hello = Printf.printf "Hello, %s!" *)
This is type-safe in an almost magical way (example REPL session):
# hello 1;;
Error: This expression has type int but an expression was expected of type
string
It can however be a little tricky to wrap your head around:
# let bob …
error example format hello ocaml session string strings style type
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Senior Machine Learning Engineer
@ GPTZero | Toronto, Canada
Software Engineer III -Full Stack Developer - ModelOps, MLOps
@ JPMorgan Chase & Co. | NY, United States
Senior Lead Software Engineer - Full Stack Senior Developer - ModelOps, MLOps
@ JPMorgan Chase & Co. | NY, United States
Software Engineer III - Full Stack Developer - ModelOps, MLOps
@ JPMorgan Chase & Co. | NY, United States
Research Scientist (m/w/d) - Numerische Simulation Laser-Materie-Wechselwirkung
@ Fraunhofer-Gesellschaft | Freiburg, DE, 79104
Research Scientist, Speech Real-Time Dialog
@ Google | Mountain View, CA, USA