permute example

From: John Lloyd <jwl_at_cs.bris.ac.uk>
Date: Fri, 4 Jul 1997 01:36:09 +0100 (BST)

> Now the example, a program to compute a permutation of a list.
>
> [] ++ x = x
> (x:xs) ++ y = x:xs++y
> permute [] = []
> permute (x:xs) | u++v == permute xs = u++[x]++v


I've followed the debate between Sergio and Phil on this example but I'm
still bemused by it all. One can write permute in lots of different ways and
one can use techniques such as lazy evaluation to efficiently produce one
permutation. All these solutions look pretty much equally attractive to me.

So please can someone say exactly what it is about this example which makes
it interesting?

Also exactly what light does it throw on the narrowing vs. rewriting debate?


John
Received on Fri Jul 04 1997 - 03:37:00 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 18 2019 - 07:15:04 CEST