From: Johann Spies <jspies@maties.sun.ac.za>
To: ocaml mailing list <caml-list@inria.fr>
Subject: [Caml-list] Please help a newbie
Date: 02 Aug 2001 13:42:13 +0000 [thread overview]
Message-ID: <87lml2a896.fsf@#maties.sun.ac.za> (raw)
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
next reply other threads:[~2001-08-02 11:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-08-02 13:42 Johann Spies [this message]
2001-08-02 12:54 ` Frank Atanassow
2001-08-02 13:01 ` Francois Thomasset
2001-08-02 13:25 ` Francois Thomasset
2001-08-02 13:05 ` Sven
-- strict thread matches above, loose matches on Subject: below --
2001-08-03 10:58 Johann Spies
2001-08-03 18:23 ` [Caml-list] Please help a newbie md5i
2001-08-05 21:37 ` John Max Skaller
2001-08-02 13:37 Dave Berry
2001-08-02 16:08 ` Brian Rogoff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='87lml2a896.fsf@#maties.sun.ac.za' \
--to=jspies@maties.sun.ac.za \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox