OCaml - List - Creating a list

As all programming languages, it is possible to create lists in OCaml.

So, let's see this, right now with new examples.
We will indeed create two functions, one of ints and another of strings.

For the ints:

#let number =  [1; 2; 3; 4];;
For the strings:
#let fruits =  ["apricot"; "raspberry"; "cherry"; "tomato"];;
As you can see, there is no need to tell to the interpreter the type of elements in the list.
It's automatic! smiley

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.