this is whatlittle F# I've done so far:

1
2
3
4
5
6
7
8
(*Sort*)
let FSSortList L = List.stable_sort compare;
(*Invert*)
let FSInvertList L =  List.rev L;
(*Add Non-sorted*)
let FSAddNonSortedElement E L = List.rev (E :: (List.rev L));
(*Add Sorted*)
let FSAddSortedElement E L = E :: L |> FSSortList;

In C# I have:

1
List<object> Lx   //with some data - strings

When I try linking two, I can't. I don't know what to give him...

I'd like stg like:

1
Lx = FSSortList(Lx);

and I know It's stg like:

1
Lx = REFERENCE.FSSort<SOMETHING>(SOMETHING2);

but what is SOMETHING & SOMETHING2???

By on 5/25/2008 12:48 PM ()

Hi morrak,

In orderto make your F# code apper properly to C#, you should

1. Wrap the mulitple parameters in a parenthesis

let FSAddNonSortedElement E L -> let FSAddNonSortedElement (E, L)

2. Use.NET types. In this case, use ResizeArray instead of F# List. Resize arrays map to System.Collections.Generic.List (which is probably what your C# code will pass and expect as a return value) while F# list belong Microsoft.FSharp.Collections.List

FSAddNonSortedElement can be rewritten to:

1
2
3
4
5
let FSAddNonSortedElement2 (E, L) = 

  let temp =  ResizeArray.append ( E ) (ResizeArray.rev L)

  ResizeArray.rev temp
By on 5/25/2008 8:53 PM ()

thx man, it rocks now with ArrayList transition...

who'd know that C#.List =/= F#.List

Thx again!

By on 5/26/2008 1:37 AM ()
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