English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
recursion/iterator question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-04-16 (21:12)
From: Tato Thetza <thetza@s...>
Subject: recursion/iterator question
Hi caml-list
Given a list, I would like to iterate over all triplets in the list. For
example, in mathematcs, its not uncommon to have expressions such as
"for all i,j,k in set X, do f(i,j,k)"

The only way I can think of is to create a list with all triplets of the
list, so:
  triplets([1,2,3,4]) = [(1,2,3),(1,2,4),(1,3,4),(2,3,4)]
and take this list and map a function f to it.

1) what would be the best way to write triplets?
2) is there a cleaner way to iterate over all triplets in a list?

please excuse my english
Tato T.