[Haskell-beginners] Missing termination rule for recursive function
Daniel Fischer
daniel.is.fischer at googlemail.com
Tue Nov 6 00:53:27 CET 2012
On Tue, Nov 6, 2012 at 12:45 AM, Oscar Benjamin
<oscar.j.benjamin at gmail.com>wrote:
> On 5 November 2012 21:00, Daniel Fischer wrote
>
> > and the former is not even correct, because there is exactly one
> permutation
> > of an empty list.
>
> I'm trying to convince myself that this is logically necessary but it
> still seems consistent in my mind that the set of permutations of an
> empty list is empty. I guess maybe if you posit that a sequence should
> always be contained by the set of its permutations then you reach this
> conclusion.
>
A permutation of a set is a bijection from the set to itself. There is one
map from the empty set to itself, the empty map, that is a bijection.
The number of permutations of a set of n elements is n!, and 0! = 1 should
make you expect that there is one permutation of an empty set.
>
> >
> > Trace the execution of very simple cases (empty lists, singleton lists,
> lists
> > with two elements) by hand with pencil and paper. That's the most
> instructive
> > and fruitful way.
> >
> > Check the results of simple cases against what you know the result ought
> to
> > be.
>
> I see what you mean now.
>
> > Single-step through the evaluation of simple cases in the ghci debugger
> if
> > necessary.
>
> I need to work out how to use this. I've just found why I was unable
> to use it before: it only works if the file is interpreted. The quick
> fix was to delete all files created by the compiler. Is there a way
> that I can tell ghci to just ignore those files and load my program as
> interpreted for debugging?
>
> You can
>
ghci> :load *ModuleName
to get it interpreted.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121106/4eb4965d/attachment.htm>
More information about the Beginners
mailing list