Problem #2
March 3, 2008 – 12:02 pmThe second problem seems a lot like number 2.
// Problem 02: Find the last but one element of a list
// last_but_one(X,L) :- X is the last but one element of the list L
// (element,list) (?,?)
#light
let thisList = [1; 2; 3; 4; 5; 6]
let l = List.length thisList
List.nth thisList (l - 2)
|> printf "Answer: %d"
I still haven’t really seen an F# tutorial. I am not bragging, I am apologizing since my solution is no where as refined and as elegant as the solutions that got posted at Frickensweet. I think I am doing myself a bad service by not reading up on F#. So I intend on at least reading up on the tutorials before going on.