0

How can I write a function that will check a given list and return true if the list is a string list? At the moment what I have is that it returns true for any list it is given.

let rec checklist list =
match list with 
| x :: xs ->  true
| _ -> false

checklist ["1";"2"]
Oluwagbemi Kadri
  • 400
  • 5
  • 15

1 Answers1

1

I assume this is homework.

I suggest you first write a function to determine if an object is a string or not (this might help), then look through the List module for a suitable function to test forall elements in your list.

nilekirk
  • 2,353
  • 1
  • 8
  • 9