caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: Seeking pratical tutorial or examples.
       [not found] <20001019101803A.garrigue@kurims.kyoto-u.ac.jp>
@ 2000-10-19 19:02 ` Francisco Reyes
  2000-10-19 23:55   ` multiple destructuring? Bruce Hoult
  0 siblings, 1 reply; 17+ messages in thread
From: Francisco Reyes @ 2000-10-19 19:02 UTC (permalink / raw)
  To: Jacques Garrigue; +Cc: caml-list

On Thu, 19 Oct 2000 10:18:03 +0900, Jacques Garrigue wrote:

>Caml-light has a wonderful example directory in the distribution.
>I join the README as attachment. Even as is, this can help you.


Thanks for the README.
 Pierre mentioned he is going to port the examples to Ocaml.

>Actually, the only examples in the distribution is a few samples
>in the otherlibs/labltk subdirectory, that I'm afraid very few
>people really know about.

They also may not be a good entry point for total newcomers.
The examples from the CamlLight distribution seem like the right
type. Simple yet complete enough to see a combination of
different topics (loops, input from user, etc..).


>There are good reasons why Objective Caml documentation cannot match
>that of bigger projects,

Which are? 
Need for more volunteers?
It is a cycle. The easier we make it for new people to join, the
more people we have to help with the documentation.

>but since plenty of examples are available,
>just making them easier to find would be a big help to beginner and
>intermediate programmers.

Yes. Much of the documentation would make much more sense if one
had a few examples to read. This is particularly the case for
the syntax of functions on the Standard Library (Chaper 19 of
the Ocaml Manual)
>
>Jacques Garrigue
>---------------------------------------------------------------------------
>Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
>		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>
>



francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

* multiple destructuring?
  2000-10-19 19:02 ` Seeking pratical tutorial or examples Francisco Reyes
@ 2000-10-19 23:55   ` Bruce Hoult
  2000-10-20 12:18     ` Pierre Weis
  0 siblings, 1 reply; 17+ messages in thread
From: Bruce Hoult @ 2000-10-19 23:55 UTC (permalink / raw)
  To: caml-list

I'm just starting to play with OCaml and I wrote the following function:

let rec is_sorted lst =
    match lst with
       [] -> true
    | [elt] -> true
    | a :: b :: tail -> a<b & is_sorted(b :: tail)


I'm wondering whether the b :: tail actually allocates memory or is 
the compiler smarter than that?  What's the best way to avoid this? 
If I rewrite to match instead with "a :: tail" (and then later pull 
that apart into b :: more_tail) am I guaranteed that tail is 
non-empty because of the prior [elt] case?

-- Bruce



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: multiple destructuring?
  2000-10-19 23:55   ` multiple destructuring? Bruce Hoult
@ 2000-10-20 12:18     ` Pierre Weis
  0 siblings, 0 replies; 17+ messages in thread
From: Pierre Weis @ 2000-10-20 12:18 UTC (permalink / raw)
  To: Bruce Hoult; +Cc: caml-list

> I'm just starting to play with OCaml and I wrote the following function:
> 
> let rec is_sorted lst =
>     match lst with
>        [] -> true
>     | [elt] -> true
>     | a :: b :: tail -> a<b & is_sorted(b :: tail)
> 
> 
> I'm wondering whether the b :: tail actually allocates memory or is 
> the compiler smarter than that?

Yes it does, since you explicitely asked for it.

>  What's the best way to avoid this? 

Name the input sub-pattern (b :: tail) and use it in place of an
explicit call to "::" :

let rec is_sorted lst =
  match lst with
  | [] -> true
  | [elt] -> true
  | a :: (b :: tail as first_tail) -> a < b && is_sorted first_tail

> If I rewrite to match instead with "a :: tail" (and then later pull 
> that apart into b :: more_tail) am I guaranteed that tail is 
> non-empty because of the prior [elt] case?

Yes and no. If you write:

  match lst with
  | [] -> true
  | [elt] -> true
  | a :: tail -> ...

then you are guaranted that tail cannot be empty (this is witnessed by
the compiler that cheks it and does not emit any ``partial match''
warning).

However, if you further match the tail pattern in the right hand part
of the clause, the compiler ``forgets'' this fact and performs a new
exhaustivity check from scratch:

let rec is_sorted lst =
  match lst with
  | [] -> true
  | [elt] -> true
  | a :: tail ->
     begin match tail with
     | b :: t -> a < b && is_sorted tail
     end;;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
[]
val is_sorted : 'a list -> bool = <fun>

Anyway, I would suggest a simpler solution to implement this function:

let rec is_sorted = function
  | a :: (b :: _ as t) -> a < b && is_sorted t
  | _ -> true;;

Best regards,

PS: If you allow duplicated elements in lists you should use <=
instead of < ...

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-18  5:52       ` Francisco Reyes
  2000-10-18  7:20         ` Chris Hecker
@ 2000-10-18 13:31         ` Stephan Houben
  1 sibling, 0 replies; 17+ messages in thread
From: Stephan Houben @ 2000-10-18 13:31 UTC (permalink / raw)
  To: Francisco Reyes, Francisco Reyes, Chris Hecker; +Cc: caml-list

On Wed, 18 Oct 2000, Francisco Reyes wrote:
> Chris,
> 
> Would you be willing to work with me on a sample/code snippet
> page?
> 
> For starters we could do it on our own page(s) and when we have
> enough we can try and upload them to Sourceforge.net. This way
> more people would find out about this language.

I once made a very small page that tries to explain some of the simplest
things about Ocaml (so as how to run the compiler, etc).

It's at: http://www.win.tue.nl/~stephanh/ocaml

Probably not very useful, but feel free to take anything you can use.

Stephan

-- 
ir. Stephan H.M.J. Houben
tel. +31-40-2474358 / +31-40-2743497
e-mail: stephanh@win.tue.nl



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-18  5:52       ` Francisco Reyes
@ 2000-10-18  7:20         ` Chris Hecker
  2000-10-18 13:31         ` Stephan Houben
  1 sibling, 0 replies; 17+ messages in thread
From: Chris Hecker @ 2000-10-18  7:20 UTC (permalink / raw)
  To: Francisco Reyes; +Cc: caml-list


>Would you be willing to work with me on a sample/code snippet
>page?

Yes, I'm just beginning too, but between the two of us we can probably do a couple good examples.  I'm working on transforming an array of 3D vectors, since it's a trivial thing to measure performance- and readability-wise.  It's also kind of non-functional by nature, but there are ways of making it functional (map, etc.).  I'm also comparing the performance to C code, so I'll have a nice set of examples and transformations on the initial codes to make them faster and/or more functional.

Chris




^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Seeking pratical tutorial or examples.
  2000-10-17 17:51 ` Chris Hecker
@ 2000-10-18  5:58   ` Francisco Reyes
  0 siblings, 0 replies; 17+ messages in thread
From: Francisco Reyes @ 2000-10-18  5:58 UTC (permalink / raw)
  To: Brent Fulgham, Chris Hecker; +Cc: caml-list

On Tue, 17 Oct 2000 10:51:01 -0700, Chris Hecker wrote:

>>Could it be that your mind is merely reeling from the unfamiliar 
>>functional programming paradigm?

>The fact of the matter is that there is a certain amount of
>logistical stuff one has to do to get a program to compile in
>any new language.

Exactly.

>We're (or I am) asking for examples of that in the main docs.

I think if we create them it would be much easier for us to ask
someone to include a link and then everyone will be happy. :-)

Of course I am just getting into undertanding Ocaml, so I may
provide some semi-trivial to start and then as I advance I can
produce better examples.

Also a lot of the examples are school/math theory oriented
(factorial, fibonaci, etc...) instead of simple examples which
anyone could understand even if they have little/no mathematical
background.


francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16 17:57     ` Chris Hecker
  2000-10-17 17:40       ` Stefan Monnier
@ 2000-10-18  5:52       ` Francisco Reyes
  2000-10-18  7:20         ` Chris Hecker
  2000-10-18 13:31         ` Stephan Houben
  1 sibling, 2 replies; 17+ messages in thread
From: Francisco Reyes @ 2000-10-18  5:52 UTC (permalink / raw)
  To: Chris Hecker; +Cc: caml-list

On Mon, 16 Oct 2000 10:57:40 -0700, Chris Hecker wrote:

>Since I wrote exactly these things, perhaps I should contribute them? 
>I just found a lot of subtle things that were different between the
>interactive sessions and trying to write real code.

Chris,

Would you be willing to work with me on a sample/code snippet
page?

For starters we could do it on our own page(s) and when we have
enough we can try and upload them to Sourceforge.net. This way
more people would find out about this language.



francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Seeking pratical tutorial or examples.
@ 2000-10-17 19:21 Brent Fulgham
  0 siblings, 0 replies; 17+ messages in thread
From: Brent Fulgham @ 2000-10-17 19:21 UTC (permalink / raw)
  To: Chris Hecker; +Cc: caml-list

> >Could it be that your mind is merely reeling from the unfamiliar 
> >functional programming paradigm?  Those of use "raised" in the school
> >of procedural C programming, or working in the Dot-Com trenches in
> >Perl are used to thinking in terms of step 1, step2, ..., etc.
> 
> Uh, speaking for myself, I think this comment is a really 
> good way to turn off people interested in exploring ocaml.  
> There's a difference between "my mind is reeling" and "I'm 
> trying to figure out where I need to put a damn semicolon".
>

Yikes -- I can see my attempt at humor was a dud.  I was just trying
to see if his problems were similar to the confusion I felt when
dealing with functional programming after many years using the
procedural style.  I apologize if I've offended anyone!  :-\
 
> The fact of the matter is that there is a certain amount of 
> logistical stuff one has to do to get a program to compile in 
> any new language.  We're (or I am) asking for examples of 
> that in the main docs.  I had to go download a bunch of 
> sample programs from unrelated sites to see how to do it.
> 
By all means -- if the information is not easily found, it should
be included in the documentation.

-Brent



^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Seeking pratical tutorial or examples.
  2000-10-16 21:46 Brent Fulgham
  2000-10-17 10:10 ` Francisco Reyes
@ 2000-10-17 17:51 ` Chris Hecker
  2000-10-18  5:58   ` Francisco Reyes
  1 sibling, 1 reply; 17+ messages in thread
From: Chris Hecker @ 2000-10-17 17:51 UTC (permalink / raw)
  To: Brent Fulgham, fran; +Cc: caml-list


>Could it be that your mind is merely reeling from the unfamiliar 
>functional programming paradigm?  Those of use "raised" in the school
>of procedural C programming, or working in the Dot-Com trenches in
>Perl are used to thinking in terms of step 1, step2, ..., etc.

Uh, speaking for myself, I think this comment is a really good way to turn off people interested in exploring ocaml.  There's a difference between "my mind is reeling" and "I'm trying to figure out where I need to put a damn semicolon".

The fact of the matter is that there is a certain amount of logistical stuff one has to do to get a program to compile in any new language.  We're (or I am) asking for examples of that in the main docs.  I had to go download a bunch of sample programs from unrelated sites to see how to do it.

You can take that as constructive criticism or you can decide my mind is reeling and write it off.  Your choice.

Chris




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16 17:57     ` Chris Hecker
@ 2000-10-17 17:40       ` Stefan Monnier
  2000-10-18  5:52       ` Francisco Reyes
  1 sibling, 0 replies; 17+ messages in thread
From: Stefan Monnier @ 2000-10-17 17:40 UTC (permalink / raw)
  To: caml-list

>>>>> "Chris" == Chris Hecker <checker@d6.com> writes:
> PS.  Should the reply-to header on list messages be set to the list so
> threads don't accidently go private if somebody doesn't reply-all?

Please no.  That makes it a pain when you really want to write a private reply.
The way it is now, you get to chose between "reply sender" and "reply all",
as Emacs intended it to be.


        Stefan

--
I believe in Emacs.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Seeking pratical tutorial or examples.
  2000-10-16 21:46 Brent Fulgham
@ 2000-10-17 10:10 ` Francisco Reyes
  2000-10-17 17:51 ` Chris Hecker
  1 sibling, 0 replies; 17+ messages in thread
From: Francisco Reyes @ 2000-10-17 10:10 UTC (permalink / raw)
  To: Brent Fulgham; +Cc: caml-list

On Mon, 16 Oct 2000 14:46:14 -0700, Brent Fulgham wrote:

>Could it be that your mind is merely reeling from the unfamiliar 
>functional programming paradigm?  Those of use "raised" in the school
>of procedural C programming, or working in the Dot-Com trenches in
>Perl are used to thinking in terms of step 1, step2, ..., etc.


Probably true, but one wants to get productive with tools
quickly.
I have to check the FAQ links that Pierre sent, but so far I
have found little that prepares the new user to be productive on
a rush.


francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: Seeking pratical tutorial or examples.
@ 2000-10-16 21:46 Brent Fulgham
  2000-10-17 10:10 ` Francisco Reyes
  2000-10-17 17:51 ` Chris Hecker
  0 siblings, 2 replies; 17+ messages in thread
From: Brent Fulgham @ 2000-10-16 21:46 UTC (permalink / raw)
  To: fran; +Cc: caml-list

Francisco (and others),

Could it be that your mind is merely reeling from the unfamiliar 
functional programming paradigm?  Those of use "raised" in the school
of procedural C programming, or working in the Dot-Com trenches in
Perl are used to thinking in terms of step 1, step2, ..., etc.

Those of us who have at least been exposed to Lisp or Scheme have
a leg up, because we were forced to think recursively and look at
a program's output as the result of the evaulation of functions.

You are probably right that some code snippets might be helpful,
but many of the references you site include many such examples.
Pierre Weis has already listed the references I have used to reach
my current novice-state familiarity with Caml, and you would be
well served to examine those documents.

I would also highly recommend Cousineau and Mauny's excellent
"The Functional Approach to Programming".  While not a Caml
tutorial, it teaches you the language as you go, and has the
added benefit of teaching you about functional programming.
If you like the venerable "Structure and Interpretation of
Computer Programming", this will be right up your alley.  Cousineau
and Mauny also include lots of useful examples of things like
quicksort (using Caml's functional approach, then again in a
more procedural way to contrast), parsing systems, tree traversal,
graphs, and more.  Highly recommended.

And of course, have fun!

-Brent



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16  7:49   ` Pierre Weis
@ 2000-10-16 17:57     ` Chris Hecker
  2000-10-17 17:40       ` Stefan Monnier
  2000-10-18  5:52       ` Francisco Reyes
  0 siblings, 2 replies; 17+ messages in thread
From: Chris Hecker @ 2000-10-16 17:57 UTC (permalink / raw)
  To: Pierre Weis, fran; +Cc: caml-list


>> Isn't there a code snippet/samples page?

I think the ocaml docs are good, but I must agree with the original poster about one thing: there is a lack of small example programs that are meant to be _compiled_.  That is, most of the examples use interactive mode.  A few examples in particular would be good:

1.  a single file ocaml program, and exactly how it's compiled with ocamlc and ocamlopt
2.  a two file example, and how it's compiled (the .mli thing confused me for a while)
3.  an example that uses an external C function

Since I wrote exactly these things, perhaps I should contribute them?  I just found a lot of subtle things that were different between the interactive sessions and trying to write real code.

Chris

PS.  Should the reply-to header on list messages be set to the list so threads don't accidently go private if somebody doesn't reply-all?




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16  5:42   ` Alan Schmitt
@ 2000-10-16 11:20     ` Francisco Reyes
  0 siblings, 0 replies; 17+ messages in thread
From: Francisco Reyes @ 2000-10-16 11:20 UTC (permalink / raw)
  To: Alan Schmitt; +Cc: caml-list

On Mon, 16 Oct 2000 07:42:37 +0200, Alan Schmitt wrote:

>If you speak French, the O'Reilly book (available online at
>http://www.editions-oreilly.fr/divers/ocaml/cdrom.html ) is a great
>source of examples.

I don't speak French so i ordered a book at amazon.com: The
Functional Approach to Programming.


francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16  0:52 ` Seeking pratical tutorial or examples Francisco Reyes
  2000-10-16  5:42   ` Alan Schmitt
@ 2000-10-16  7:49   ` Pierre Weis
  2000-10-16 17:57     ` Chris Hecker
  1 sibling, 1 reply; 17+ messages in thread
From: Pierre Weis @ 2000-10-16  7:49 UTC (permalink / raw)
  To: fran; +Cc: caml-list

> I have looked at the caml site, the hump and all I links I could
> find from the main site.
[...]

In my mind, it seems as if you have completely missed the FAQ of the
language ...

> Isn't there a code snippet/samples page?
> 
> What I have tried so far are the intro on the Ocaml Manual,  the
> "Functional Programming using Caml light" and "One hundred lines
> of Caml".
> 
> Comments on the 3 sources I mentioned above:
> ** Ocaml Manual: The intro is not bad, except that for those of
> us coming from languages without a built in interactive system
> we may not be as interested to start with that. Why? because
> although great for learning it is of not much use unless we just
> want to try simple things. [...]

Bizarre: you do not want to start by simple things ?

If you do want to start by material that are not ``simple things'',
you definitely have to read the pretty good bunch of examples that is
generally refered to as ``the Objective Caml compiler''. It is not
interactive, it is great for learning, and in some cases definitively
not simple (I would suggest the following road-map: start with the
Objective Caml libraries (directories stdlib and otherlibs), then
bravely start reading the compiler sources: first the Yacc parser and
its associated lexer (directory parsing), then take a breath and read
the type-checker (directory typing), breath again and continue with
the pattern matching compiler (directory bytecomp), then breath a lot
and end with the delicious native code compiler (directory asmcomp)).

> I think the following order may be more benefitial to someone
> coming from languages such as C/pascal.

Excellent: you are exactly describing the order of presentation of the
FAQ, that has been intended for just that kind of people. The first
page of the FAQ for beginners, has the following items entries, in
that order:

* What is the syntax of the language ? 
* What are the basic data structures ? 
  * Numbers: integers and floating point numbers. 
  * Characters 
  * Character strings 
  * Arrays 
  * Lists 
  * Booleans 
  * Nothing 
  * References 
  * Pairs 
  * Other data structures 
* What are the basic control structures ? 
  * How to perform a test ? 
  * How to perform a case analysis ? 
  * How to perform a test within a case analysis ? 
  * How to write a loop ? 
  * How to exit form a loop ? (break, exit, abort, return ...) 
  * How to catch errors ? 
  * How to signal errors (raise exceptions) ? 
  * What are the predefined exceptions (errors) ? 
* How to define a function ? 
* How to define a procedure ? 

> -Start by having something which shows a compiled program and a
> few basic statements (i.e. ask for name and then print hello
> <name>. 

http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#quellesyntaxe

> -Cover data types and show the functions to read them and
> display them. No fancy explanation about "channels" just give
> examples using print functions and whatever is used to read info
> into a variable.

http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#donnees_de_base-eng.html

> -Loops and branching: "for" and "if"

http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#controle_de_base-eng.html

While, match and exceptions are also covered.

> -Cover functions

http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#function_definition

> -Basic file I/O

http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#ios

Printing is also covered at:
http://pauillac.inria.fr/caml/FAQ/FAQ_DEBUTANT-eng.html#impression

> -String handling

http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#strings

> -More advanced data structures/types: arrays, user defined data
> types, lists.

http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#vects
http://pauillac.inria.fr/caml/FAQ/donnees_de_base-eng.html#lists
http://pauillac.inria.fr/caml/FAQ/qrg-eng.html

> -The interactive system

http://pauillac.inria.fr/caml/FAQ/

> And of course on all those steps start showing the user the way
> things are written in Ocaml and how things are called in it.

The same references, plus the Quick Reference Guide for Caml that
gives you the syntactic constructs along with examples:
http://pauillac.inria.fr/caml/FAQ/qrg-eng.html

> ** Functional Programming using Caml Light
> I am up to chapter 5 and I am yet to dream of how to actually
> write a complete program. Even after I jumped chapters ahead to
> chapter 9, Basic I/O, there are one line descriptions or trivial
> use of the fucntions, but I didn't even see a simple brief
> program to show all elements together. The document almost seems
> like reference material, except that it is too
> descriptive/narrative to be that.

Right. It is not a reference manual, although it describes a
type-checker and a compiler for (a subset of) Caml.

> ** One Hundred lines of Ocaml: This is enough to give a "taste"
> of the language, but far from been enough to start hacking.

Right, it just appears in the FAQ under the title:
A taste of Caml

> Have a missed a kinder/gentler tutorial somewhere?

May be the FAQ ?

> Somewhere on the caml site I saw a mention about a series of
> examples that come with the compiler. The FreeBSD port I got
> didn't have them and I was unable to find them on the web site
> (caml.inria.fr)

Those examples are written for Caml Light and burried from the book
``Le langage Caml''. I translated them into Objective Caml, but have
not linked them to the Caml web site, since there is no english
explanations on those examples (the book ``Le langage Caml'' has not
yet been translated into english).

> francisco
> Moderator of the Corporate BSD list
> http://www.egroups.com/group/BSD_Corporate

PS1: I hope you will find what you need in the FAQ. In any case,
please let me know if you have some addition to suggest to the FAQ's
tutorial.

PS2: Also, when you are writing your first big Caml programs, don't
miss the very relevant Caml Programming Guide Lines:

http://pauillac.inria.fr/caml/FAQ/pgl-eng.html

that also gives some useful hints on how to program in Caml.

Pierre Weis

Moderator of the Caml list
http://pauillac.inria.fr/caml/FAQ/




^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: Seeking pratical tutorial or examples.
  2000-10-16  0:52 ` Seeking pratical tutorial or examples Francisco Reyes
@ 2000-10-16  5:42   ` Alan Schmitt
  2000-10-16 11:20     ` Francisco Reyes
  2000-10-16  7:49   ` Pierre Weis
  1 sibling, 1 reply; 17+ messages in thread
From: Alan Schmitt @ 2000-10-16  5:42 UTC (permalink / raw)
  To: Francisco Reyes; +Cc: caml-list

Hi,

If you speak French, the O'Reilly book (available online at
http://www.editions-oreilly.fr/divers/ocaml/cdrom.html ) is a great
source of examples.

Alan Schmitt

>I have looked at the caml site, the hump and all I links I could
>find from the main site.
>So far the manuals/tutorials I have seen did not "quick start"
>my development intentions.
>
>I am looking for a pratical tutorial or some simple beginner
>examples. After days of reading the manuals I am yet to be able
>to write even a simple program. Even when I skip sections on the
>manuals they still don't offer anything beyond Syntax.
>
>Isn't there a code snippet/samples page?
[..]

--
The hacker: someone who figured things out and made something cool happen.



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Seeking pratical tutorial or examples.
  2000-10-14 15:59 OCaml sync tool for Rex organizer bcpierce
@ 2000-10-16  0:52 ` Francisco Reyes
  2000-10-16  5:42   ` Alan Schmitt
  2000-10-16  7:49   ` Pierre Weis
  0 siblings, 2 replies; 17+ messages in thread
From: Francisco Reyes @ 2000-10-16  0:52 UTC (permalink / raw)
  To: caml-list

I have looked at the caml site, the hump and all I links I could
find from the main site.
So far the manuals/tutorials I have seen did not "quick start"
my development intentions.

I am looking for a pratical tutorial or some simple beginner
examples. After days of reading the manuals I am yet to be able
to write even a simple program. Even when I skip sections on the
manuals they still don't offer anything beyond Syntax.

Isn't there a code snippet/samples page?

What I have tried so far are the intro on the Ocaml Manual,  the
"Functional Programming using Caml light" and "One hundred lines
of Caml".

Comments on the 3 sources I mentioned above:
** Ocaml Manual: The intro is not bad, except that for those of
us coming from languages without a built in interactive system
we may not be as interested to start with that. Why? because
although great for learning it is of not much use unless we just
want to try simple things. It also falls short of giving enough
info to get one started.

I think the following order may be more benefitial to someone
coming from languages such as C/pascal.
-Start by having something which shows a compiled program and a
few basic statements (i.e. ask for name and then print hello
<name>. 

-Cover data types and show the functions to read them and
display them. No fancy explanation about "channels" just give
examples using print functions and whatever is used to read info
into a variable.

-Loops and branching: "for" and "if"

-Cover functions

-Basic file I/O

-String handling

-More advanced data structures/types: arrays, user defined data
types, lists.

-The interactive system

And of course on all those steps start showing the user the way
things are written in Ocaml and how things are called in it.


** Functional Programming using Caml Light
I am up to chapter 5 and I am yet to dream of how to actually
write a complete program. Even after I jumped chapters ahead to
chapter 9, Basic I/O, there are one line descriptions or trivial
use of the fucntions, but I didn't even see a simple brief
program to show all elements together. The document almost seems
like reference material, except that it is too
descriptive/narrative to be that.


** One Hundred lines of Ocaml: This is enough to give a "taste"
of the language, but far from been enough to start hacking.

Have a missed a kinder/gentler tutorial somewhere?
Somewhere on the caml site I saw a mention about a series of
examples that come with the compiler. The FreeBSD port I got
didn't have them and I was unable to find them on the web site
(caml.inria.fr)


francisco
Moderator of the Corporate BSD list
http://www.egroups.com/group/BSD_Corporate




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2000-10-20 12:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20001019101803A.garrigue@kurims.kyoto-u.ac.jp>
2000-10-19 19:02 ` Seeking pratical tutorial or examples Francisco Reyes
2000-10-19 23:55   ` multiple destructuring? Bruce Hoult
2000-10-20 12:18     ` Pierre Weis
2000-10-17 19:21 Seeking pratical tutorial or examples Brent Fulgham
  -- strict thread matches above, loose matches on Subject: below --
2000-10-16 21:46 Brent Fulgham
2000-10-17 10:10 ` Francisco Reyes
2000-10-17 17:51 ` Chris Hecker
2000-10-18  5:58   ` Francisco Reyes
2000-10-14 15:59 OCaml sync tool for Rex organizer bcpierce
2000-10-16  0:52 ` Seeking pratical tutorial or examples Francisco Reyes
2000-10-16  5:42   ` Alan Schmitt
2000-10-16 11:20     ` Francisco Reyes
2000-10-16  7:49   ` Pierre Weis
2000-10-16 17:57     ` Chris Hecker
2000-10-17 17:40       ` Stefan Monnier
2000-10-18  5:52       ` Francisco Reyes
2000-10-18  7:20         ` Chris Hecker
2000-10-18 13:31         ` Stephan Houben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).