Get last item from List in F#

less than 1 minute read

In C#, you use bang (!) to negate a boolean expression. Unfortunately, not in F#. it’s “not”

List is a linked list in F#. Head is an element but Tail is a List. How can you get the last element? Anything like list.Last()? Simple trick would be, if you don’t consider performance, though …

myList |> List.rev |> List.head

You can create a list of alphabets like

let list = ['a' .. 'z']