4 people like it.
Like the snippet!
String palindrome (short)
Dear #fssnip newbies, please do not write F# code as if you are still in C#. Direct ports are meaningless. Among other things, please learn what structural equality is.
1:
2:
3:
4:
5:
6:
7:
8:
|
open System
let isPal str =
let str = str |> Seq.filter ((<>) ' ') |> Seq.toList
str = (str |> List.rev)
["abc ba"; "abcba"; "a"; "aaba"; ""]
|> List.map (fun x -> x, isPal x)
|
namespace System
val isPal : str:seq<char> -> bool
Full name: Script.isPal
val str : seq<char>
val str : char list
module Seq
from Microsoft.FSharp.Collections
val filter : predicate:('T -> bool) -> source:seq<'T> -> seq<'T>
Full name: Microsoft.FSharp.Collections.Seq.filter
val toList : source:seq<'T> -> 'T list
Full name: Microsoft.FSharp.Collections.Seq.toList
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 map : mapping:('T -> 'U) -> list:'T list -> 'U list
Full name: Microsoft.FSharp.Collections.List.map
val x : string
More information