Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Please help a newbie
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Johann Spies <jspies@m...>
Subject: [Caml-list] Please help a newbie
I have read a lot of tutorials and examples and am now trying to write
something myself.  My problem will show that I do not understand a
basic thing in functional programming.  I will appreciate some help on
this.

The following illustrates my problem:

------------------
$ ocaml
        Objective Caml version 3.01

# let lys = ['a';'b';'c'];;
val lys : char list = ['a'; 'b'; 'c']
# let wys_dit woord = print_string woord;;
val wys_dit : string -> unit = <fun>
# let rec wys_die_lys l = function
    [] -> []
        | h :: t -> wys_dit h ::    wys_die_lys l t;;
val wys_die_lys : 'a -> string list -> unit list = <fun>
# wys_die_lys lys;;
- : string list -> unit list = <fun>
# wys_die_lys ['x','y','z'];;
- : string list -> unit list = <fun>
------------------------------------------------

Now my question:  I expected 

wys_die_lys lys to print out a b c
and 
wys_die_lys ['x','y','z'] to print x y z

Why did this not happen?


Johann
-- 
Johann Spies          Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

     "All scripture is given by inspiration of God, and is 
      profitable for doctrine, for reproof, for correction, 
      for instruction in righteousness;"          
                                     II Timothy 3:16 
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr