$(use "env3.ml") Trial with simple functions: --------------------------- f is let f x = "My argument was \$(x)";; t is let t = "named t";; y is let y = "\$(f t)";; # Applying f to t (which is bound to ``$(t)'') leads to # ``$(y)''. let concat x y = "\$(x)\$(y)";; let z = \$t;; let u = \$(concat "con" "catenation");; Applying concat to "con" and "catenation" gives # `` $(u) ''. --------------------------- Trial with the htmlc function title: we evaluate \$(title "Function application") --------------------------- $(title "Function application") --------------------------- Trial with function expand: we evaluate \$(expand \$(title "Function application")) --------------------------- $(expand $(title "Function application")) --------------------------- Leftering stuff. --------------------------- $(flush_left_gen "_" "This is the end" 78) --------------------------- Centering stuff. --------------------------- $(center_gen "@" "This is the end" 78) --------------------------- Rightering stuff. --------------------------- $(flush_right "This is the end" 78) --------------------------- Putting stuff in upper case characters. --------------------------- $(uppercase "you have been warned!") --------------------------- Putting stuff in lower case characters. --------------------------- $(lowercase "LaTeX") --------------------------- Capitalizing stuff. --------------------------- $(capitalize "paris") --------------------------- Creating a string. --------------------------- H$(string_make "a" 42)... --------------------------- Computing the length of the previous line. --------------------------- $(line) The previous line is $(string_length line) characters long. --------------------------- A blank string between two sharp-signs. --------------------------- #$(blank 42)# --------------------------- Computing the release ident. --------------------------- My_soft $(release_ident "1" "0") Htmlc $(release_ident "1" "80") OCaml $(release_ident "3" "09") LaTeX $(release_ident "3" "14") --------------------------- Computing the distribution ident. --------------------------- Htmlc $(distribution_ident "1" "80" "development" "12") OCaml $(distribution_ident "3" "09" "patch" "4") LaTeX $(distribution_ident "3" "14" "release_candidate" "159") My_soft $(distribution_ident "0" "0" "alpha" "42") Your_soft $(distribution_ident "0" "0" "beta" "0") --------------------------- Computing the version full info. --------------------------- LaTeX $(version_full_info "3" "14" "release_candidate" "159" "by a gibbous moon" "2007-08-09") My_soft $(version_full_info "0" "0" "alpha" "42" "reimplemented from scratch" "2005-06-07") --------------------------- Computing arithmetic operations. --------------------------- (42 - 2) + 2 = $(plus $(minus forty_two 2) 2) (42 + 2) - 2 = $(minus $(plus forty_two 2) 2) (42 / 2) * 2 = $(multiply $(divide forty_two 2) 2) (42 * 2) / 2 = $(divide $(multiply forty_two 2) 2) (sqrt 42) ** 2 = $(power $(sqrt forty_two) 2) sqrt(42 ** 2) = $(sqrt $(power forty_two 2)) sqrt(3 ** 2 + 4 ** 2) = $(sqrt "$(plus $(power 3 2) $(power 4 2))") --------------------------- Computing arithmetic operations with 2-decimal results. --------------------------- sqrt(1+1) is almost $(two_decimals "$(sqrt $(plus 1 1))"). 1/3 is almost $(two_decimals $(divide 1 3)) then 3 * (1/3) is almost $(multiply 3 "$(two_decimals $(divide 1 3))"), but 3 * (1/3) is exactly $(two_decimals "$(multiply 3 $(divide 1 3))"). --------------------------- Computing arithmetic operations with 0-decimal results. --------------------------- sqrt(1+1) is almost $(no_decimals "$(sqrt $(plus 1 1))"). 1/3 is almost $(no_decimals $(divide 1 3)) then 3 * (1/3) is almost $(multiply 3 "$(no_decimals $(divide 1 3))"), but 3 * (1/3) is exactly $(no_decimals "$(multiply 3 $(divide 1 3))"). --------------------------- Conditionals --------------------------- Quand Pifou content, Pifou faire "$(conditional "true" "glop glop" "pas glop pas glop")"; mais quand Pifou pas content, Pifou faire "$(conditional "false" "glop glop" "pas glop pas glop")". Quand Pifou content, Pifou faire "$(pifou_content "true")"; mais quand Pifou pas content, Pifou faire "$(pifou_content "false")". The empty string is empty: $(is_empty "")! The empty string is not empty: $(is_empty "foo"). With an empty URL string, we simply display the text: $(conditional $(is_empty "") "text" $(link "" "text")), but with a nonempty URL string, we display the corresponding link: $(conditional $(is_empty "url") "text" $(link "url" "text")). With an empty URL string, we simply display the text: $(safe_link empty_url "text"), but with a nonempty URL string, we display the corresponding link: $(safe_link nonempty_url "text"). ---------------------------