Previous week Up Next week


Here is the latest Caml Weekly News, for the week of February 05 to 12, 2008.

  1. Palindromic Quine
  2. Calendar library: version 2.0
  3. Ropes-Based Implementation of Buffer

Palindromic Quine


Concluding this thread, Keisuke Nakano said:
The shortest code contest 'Palindromic Quine' is over.
The result is found at:

Finally I could find the shortest code with 199 bytes:

"k\"",let rec(!)n?(q=String.make 1(Char.chr 34))s k=print_char(q^s^q^q^k^q).[abs n];!(n-1)s k in!99"99!ni k s)1-n(!;]n sba[.)q^k^q^q^s^q(rahc_tnirp=k s))43 rhc.rahC(1 ekam.gnirtS=q(?n)!(cer tel,""\k"

It is an acceptable solution for the contest though the code
execution ends with an exception 'index out of bounds'.

There may exist a palindromic Quine code shorter than this code.
Please try to find it if you're interested in.

Calendar library: version 2.0


Julien Signoles announced:
I am happy to announce a new release (v2.0) of Calendar, an ocaml library 
managing dates and times. This release provides a bunch of new modules and 

The library is available at:

The changes between the last version (v1.10) and this new one are:
* licence changes from LGPLv2 to LGPLv2.1
* use -pack: all modules of the library are packed inside a single module
 CalendarLib (calendar now requires ocaml >= 3.09.1)
* new modules Time_sig, Date_sig and Calendar_sig
* new module Ftime (time implementation in which seconds are floats)
 (Hezekiah M. Carty's suggestion)
* new module Calendar_builder (generic calendar implementation)
* new module Fcalendar (calendar implementation using Ftime)
* new module Calendar.Precise (calendar with a best precision)
* hash functions are provided
* new modules Printer.Ftime and Printer.Fcalendar
* modules Printer.Date, Printer.Time and Printer.Calendar respectively
 replace Printer.DatePrinter, Printer.TimePrinter and
 Printer.CalendarPrinter. These last modules still exist but are
* new function Time_Zone.on
* new function Date.from_day_of_year (Hezekiah M. Carty's suggestion)
* new function Date.is_valid_date (Richard Jones' suggestion)
* new module Utils
* new module Version (information about version of calendar)
* add tags @example, @raise and @see in the API documentation

Ropes-Based Implementation of Buffer


Deep in this thread, Jean-Christophe Filliâtre said:
Just for fun, I wrote a ropes-based implementation of Buffer. The
interface is exactly the same. Differences between the two
implementations are the following:

- Contrary to ocaml's standard library, a buffer size is not limited to
     [Sys.max_string_length], but to [max_int] (sizes are represented
     internally using native ocaml integers).

- [contents] and [sub] raise [Invalid_argument] if the resulting string
     would be larger than [Sys.max_string_length] bytes.

- The meaning of [create]'s argument is not exactly the same,
   though its value only affects performances, as for [Buffer];
   see below.

- An additional function [print] is provided.

The code is here:

For general-purpose ropes, see

Using folding to read the cwn in vim 6+

Here is a quick trick to help you read this CWN if you are viewing it using vim (version 6 or greater).

:set foldmethod=expr
:set foldexpr=getline(v:lnum)=~'^=\\{78}$'?'<1':1

If you know of a better way, please let me know.

Old cwn

If you happen to miss a CWN, you can send me a message and I'll mail it to you, or go take a look at the archive or the RSS feed of the archives.

If you also wish to receive it every week by mail, you may subscribe online.

Alan Schmitt