CookBook/FirstSteps.thy
changeset 114 13fd0a83d3c3
parent 108 8bea3f74889d
child 118 5f003fdf2653
equal deleted inserted replaced
113:9b6c9d172378 114:13fd0a83d3c3
   641 
   641 
   642 text {* While just syntactic sugar for the usual function application,
   642 text {* While just syntactic sugar for the usual function application,
   643   the purpose of this combinator is to implement functions in a  
   643   the purpose of this combinator is to implement functions in a  
   644   ``waterfall fashion''. Consider for example the function *}
   644   ``waterfall fashion''. Consider for example the function *}
   645 
   645 
   646 ML %linenumbers{*fun inc_by_five x =
   646 ML %linenosgray{*fun inc_by_five x =
   647   x |> (fn x => x + 1)
   647   x |> (fn x => x + 1)
   648     |> (fn x => (x, x))
   648     |> (fn x => (x, x))
   649     |> fst
   649     |> fst
   650     |> (fn x => x + 4)*}
   650     |> (fn x => x + 4)*}
   651 
   651 
   704   you to get hold of an intermediate result (to do some side-calculations for
   704   you to get hold of an intermediate result (to do some side-calculations for
   705   instance). The function
   705   instance). The function
   706 
   706 
   707  *}
   707  *}
   708 
   708 
   709 ML %linenumbers{*fun inc_by_three x =
   709 ML %linenosgray{*fun inc_by_three x =
   710      x |> (fn x => x + 1)
   710      x |> (fn x => x + 1)
   711        |> tap (fn x => tracing (makestring x))
   711        |> tap (fn x => tracing (makestring x))
   712        |> (fn x => x + 2)*}
   712        |> (fn x => x + 2)*}
   713 
   713 
   714 text {* 
   714 text {*