Hi Harry,

Welcome to the forum.

List.permute's type is:

((int -> int) -> 'a list -> 'a list

You can see this in Visual Studio by hovering over an invocation of List.permute.

This means it is a function which takes as arguments:

  • another function that takes an int and returns an int
  • a list containing type 'a

and which returns another list.

The function (int->int) that you should give to permute is the permutation function; you could think of it as a map from an index in the original list to the index of that element in the list that permute returns.

For example, suppose you'd want to reverse a list, then you could make the following permutation function:

1
 let reverse len orig = len - orig - 1 

This function takes the length of the list to reverse as argument, and the position of the original element, and then returns the position of that element in the reversed list.You can use it with permute as follows:> List.permute (reverse 3) [1;2;3];;
val it : int list = [3; 2; 1]As a side note, F# interactive is the ideal playground for finding out how these things work. That's how I found out ;)hope this helps,Kurt

By on 2/8/2009 8:57 AM ()

Kurt,

Yup, that helps.

Thanks.

Harry Reed

By on 2/11/2009 7:43 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper