By Emmanuel Chailloux, Pascal Manoury, Bruno Pagano

Show description

Read Online or Download Developing Applications with Objective Caml PDF

Best programming: programming languages books

Essential Java Fast : How to write object oriented software for the Internet

Java is a brand new and interesting object-oriented programming language that is set to rework the area extensive internet. Java permits clients to jot down functions which might be accessed throughout varied systems and gives an efficient technique of construction small yet robust courses that let an immense variety of latest functions - comparable to animation, dwell updating, two-way interactions and so on.

Designing SQL Server 2000 Databases. for .Net ™ Enterprise Servers

The Microsoft . internet initiative is the way forward for e-commerce - making it attainable for organizations to construct a safe, trustworthy e-commerce infrastructure. this can be the 1st ebook to stipulate the features of SQL Server 2000, one of many key parts of . internet. SQL Server 2000 introduces strong new info mining performance designed particularly to trap and approach buyer profiles and to foretell destiny purchasing styles on e-commerce websites.

Extra info for Developing Applications with Objective Caml

Example text

Functions to access a triplet (and other tuples) are not defined by the core library. One can use pattern matching to define them if need be (see page 34). Lists Values of the same type can be gathered into a list. A list can either be empty or consist of elements of the same type. # [] ; ; - : ’a list = [] 18 Chapter 2 : Functional programming # [ 1 ; 2 ; 3 ] ;; - : int list = [1; 2; 3] # [ 1 ; "two" ; 3 ] ; ; Characters 14-17: This expression has type int list but is here used with type string list The function which adds an element at the head of a list is the infix operator :: .

Let succ x = x+1 ; ; val succ : int -> int = # let compose f g x = f(g x) ; ; val compose : (’a -> ’b) -> (’c -> ’a) -> ’c -> ’b = # compose fact succ 8 ; ; - : int = 362880 This last call carries out the computation fact(succ 8) and returns the expected result. Let us note that the functions fact and succ are passed as parameters to compose in the same way as the natural number 8. 2 Functional programming The first functional language, Lisp, appeared at the end of the 1950’s. That is, at the same time as Fortran, the first representative of the imperative languages.

Here is an example of a value that is not matched: 0 val f : int -> int = # f 1 ;; - : int = 3 # f 4 ;; Uncaught exception: Match_failure("", 11, 30) The Match Failure exception is raised by the call to f 4, and if it is not handled induces the computation in progress to halt (see 54) Combining patterns Combining several patterns lets us obtain a new pattern which can match a value according to one or another of the original patterns. The syntactic form is as follows: Syntax : p1 | . . | pn It constructs a new pattern by combining the patterns p1 , .

Download PDF sample

Rated 4.41 of 5 – based on 35 votes