From: Stefano Zacchiroli <zack@cs.unibo.it>
To: caml-list@inria.fr
Subject: Re: [Caml-list] New to OCaml: can someone explain how this code can be done better?
Date: Mon, 25 Jun 2001 20:40:07 +0200 [thread overview]
Message-ID: <20010625204007.A7057@cs.unibo.it> (raw)
In-Reply-To: <3B34F067.CD965358@cmu.edu>
On Sat, Jun 23, 2001 at 03:39:19PM -0400, Eric C. Cooper wrote:
> characters. As you'll see, the only imperative code is in this
> conversion step; the rest is purely functional.
:-((
let rec explode_string = function
"" -> []
| s -> (String.get s 0) :: explode_string (String.sub s 1 (String.length s - 1))
;;
let rec implode_string = function
[] -> ""
| h::t -> (String.make 1 h) ^ implode_string t
;;
Sorry, I can't resist :-)
Cheers.
--
Stefano "Zack" Zacchiroli <zack@cs.unibo.it> ICQ# 33538863
Home Page: http://www.students.cs.unibo.it/~zacchiro
Undergraduate student of Computer Science @ University of Bologna, Italy
- Information wants to be Open -
-------------------
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 prev parent reply other threads:[~2001-06-25 18:40 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-23 5:27 Jeremy Fincher
2001-06-23 19:39 ` Eric C. Cooper
2001-06-25 18:40 ` Stefano Zacchiroli [this message]
2001-06-24 5:49 Jeremy Fincher
2001-06-24 6:03 Jeremy Fincher
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=20010625204007.A7057@cs.unibo.it \
--to=zack@cs.unibo.it \
--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;
as well as URLs for NNTP newsgroup(s).