Разработка на коленке

"тут должна быть красивая цитата о программировании"

Mistake in broken code example

2015-09-02 15:15

I read a book Real World OCaml (well, actually, I read russian edition, but that doesn't matter), and I found one funny thing - authors made an mistake in broken code example.

Chapter 2 - Prefix and Infix Operators, and code part 36, just after this.

# let (^>) x f = f x;;

# Sys.getenv_exn "PATH"
  ^> String.split ~on:':' path
  ^> List.dedup ~compare:String.compare
  ^> List.iter ~f:print_endline
  ;;

Variable path can't be used here. If you will replace ^> with |> then you get an error.