Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6690993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:42:02+00:00 2026-05-26T05:42:02+00:00

At the ocaml toplevel (version 3.11.2), this simple expression is giving me an error:

  • 0

At the ocaml toplevel (version 3.11.2), this simple expression is giving me an error:

# let a = [] in if null a then 0 else 1;;
Error: Unbound value null

I have just started learning ocaml from the oreilly book, which seems to use null as a keyword frequently – for example, top of page 32:

# let rec size a_list =
    if null a_list then 0
    else 1 + (size (List.tl a_list));;

I’m embarrassed to ask such an obviously googleable question here. But after much googling I came up empty-handed. So I’m as open to google query suggestions as I am to straightforward answers. (failed google attempts: [ocaml “Error: Unbound value null”] [ocaml null keyword] [ocaml changelog null] [ocaml change null] ).

Question: was null once an ocaml keyword, but no longer? Or did I install ocaml wrong or misspell something?

I can of course replace every occurrence of “null” with “[ ]” in code, but I’m surprised that a verbatim copy of code from a book gives me an error so early. Is this book full of other gotchas? I believe it was written with ocaml 2.04 in mind; is that too old? I chose it because I liked the TOC and the free availability online. Other than this null error (which I am still more ready to blame on myself than on the authors), the explanations are nice and I’m looking forward to the discussion of mixing functional & imperative style (mind-expanding for me, as someone only familiar with c/c++).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T05:42:02+00:00Added an answer on May 26, 2026 at 5:42 am

    null is defined in the book on page 31. It’s a normal function that you can define yourself:

    let null l = (l = [])
    

    This nomenclature is more or less based on Lisp, where NIL is an empty list (also written as ()) and NULL is a predicate (a function returning true or false), exactly like null above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As a beginner in Ocaml, I have this current working code: ... let ch_in
I am evaluating a very simple piece of code in Ocaml toplevel: let p5
Well in Ocaml you can do this at compile-time : let handle item =
Given this snippet of OCaml code: let rec range a b = if a
Can anyone explain this OCaml toplevel behaviour? # 1________________________________1;; - : int = 11
I have simple ocaml file test.ml 1 + 2;; I compiled it. can i
Have a look at this F#/OCaml code: type AllPossible = | A of int
I have experience with OCaml. You had to write a stub for every function
I have a OCaml library with lots of classes I need some translator to
I'm a very novice OCaml programmer so please forgive me if this is a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.