1 people like it.

toBase26

Function that converts a base 10 number into a base 26 (digits from the English alphabet) one. A=1, B=2, ..., Z=0

1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
let toBase26 num = 
    let digits = 'Z' :: ['A' .. 'Y']
    let rec conv lst x =
        match x with
        | 0 -> lst
        | _ ->  digits.[x % digits.Length] :: conv lst (x / digits.Length)
    
    new System.String(num |> conv [] |> List.rev |> List.toArray)
val toBase26 : num:int -> System.String

Full name: Script.toBase26
val num : int
val digits : char list
val conv : (char list -> int -> char list)
val lst : char list
val x : int
property List.Length: int
namespace System
Multiple items
type String =
  new : value:char -> string + 7 overloads
  member Chars : int -> char
  member Clone : unit -> obj
  member CompareTo : value:obj -> int + 1 overload
  member Contains : value:string -> bool
  member CopyTo : sourceIndex:int * destination:char[] * destinationIndex:int * count:int -> unit
  member EndsWith : value:string -> bool + 2 overloads
  member Equals : obj:obj -> bool + 2 overloads
  member GetEnumerator : unit -> CharEnumerator
  member GetHashCode : unit -> int
  ...

Full name: System.String

--------------------
System.String(value: nativeptr<char>) : unit
System.String(value: nativeptr<sbyte>) : unit
System.String(value: char []) : unit
System.String(c: char, count: int) : unit
System.String(value: nativeptr<char>, startIndex: int, length: int) : unit
System.String(value: nativeptr<sbyte>, startIndex: int, length: int) : unit
System.String(value: char [], startIndex: int, length: int) : unit
System.String(value: nativeptr<sbyte>, startIndex: int, length: int, enc: System.Text.Encoding) : unit
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
val rev : list:'T list -> 'T list

Full name: Microsoft.FSharp.Collections.List.rev
val toArray : list:'T list -> 'T []

Full name: Microsoft.FSharp.Collections.List.toArray
Raw view Test code New version

More information

Link:http://fssnip.net/mZ
Posted:10 years ago
Author:Lars Wilhelmsen
Tags: radix , base26 , conversion