2 people like it.

Check if string is all upper case

Checks if a string is all in upper-case characters

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
open System

let isUpper (str : string) =
    let rec strIter isUpper arr =
        match arr with
        | [] -> isUpper
        | _ -> 
            match Char.IsLower(arr.Head) with
            | true -> strIter false []
            | false -> strIter true arr.Tail

    strIter true (Array.toList <| str.ToCharArray())
namespace System
val isUpper : str:string -> bool

Full name: Script.isUpper
val str : string
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = String

Full name: Microsoft.FSharp.Core.string
val strIter : (bool -> char list -> bool)
val isUpper : bool
val arr : char list
type Char =
  struct
    member CompareTo : value:obj -> int + 1 overload
    member Equals : obj:obj -> bool + 1 overload
    member GetHashCode : unit -> int
    member GetTypeCode : unit -> TypeCode
    member ToString : unit -> string + 1 overload
    static val MaxValue : char
    static val MinValue : char
    static member ConvertFromUtf32 : utf32:int -> string
    static member ConvertToUtf32 : highSurrogate:char * lowSurrogate:char -> int + 1 overload
    static member GetNumericValue : c:char -> float + 1 overload
    ...
  end

Full name: System.Char
Char.IsLower(c: char) : bool
Char.IsLower(s: string, index: int) : bool
property List.Head: char
property List.Tail: char list
type Array =
  member Clone : unit -> obj
  member CopyTo : array:Array * index:int -> unit + 1 overload
  member GetEnumerator : unit -> IEnumerator
  member GetLength : dimension:int -> int
  member GetLongLength : dimension:int -> int64
  member GetLowerBound : dimension:int -> int
  member GetUpperBound : dimension:int -> int
  member GetValue : [<ParamArray>] indices:int[] -> obj + 7 overloads
  member Initialize : unit -> unit
  member IsFixedSize : bool
  ...

Full name: System.Array
val toList : array:'T [] -> 'T list

Full name: Microsoft.FSharp.Collections.Array.toList
String.ToCharArray() : char []
String.ToCharArray(startIndex: int, length: int) : char []
Raw view Test code New version

More information

Link:http://fssnip.net/7TK
Posted:7 years ago
Author:Martin Lockstrom
Tags: string , upper case