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 9060813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:19:36+00:00 2026-06-16T15:19:36+00:00

Imagine I have a function with a domain of all integers bigger than 0.

  • 0

Imagine I have a function with a domain of all integers bigger than 0. I want the result of other inputs to be undefined. For the sake of simplicity, let’s say this is the increment function. In Haskell, I could achieve this with something like

f :: Integer -> Integer
f x 
  | x > 0 = x + 1
  | otherwise = undefined

Of course, the example is quite gimped but it should be clear what I want to achieve. I’m not sure how to achieve the similar in Scheme.

(define (f x)
  (if (> x 0)
      (+ x 1)
      (?????)))

My idea is to just stick an error in there but is there any way to replicate the Haskell behaviour more closely?

  • 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-06-16T15:19:37+00:00Added an answer on June 16, 2026 at 3:19 pm

    Your question is related to this one which has answers pointing out that in R5RS (which I guess MIT scheme partially supports?), the if with one branch returns an “unspecified value”. So the equivalent to the haskell code should be:

    (define (f x)
      (if (> x 0)
          (+ x 1)))
    

    You probably already know this: in haskell undefined is defined in terms of error, and is primarily used in development as a placeholder to be removed later. The proper way to define your haskell function would be to give it a type like: Integer -> Maybe Integer.

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

Sidebar

Related Questions

Let's imagine I have an unknown function that I want to approximate via Genetic
Imagine I have a template function like this: template<typename Iterator> void myfunc(Iterator a, typename
Imagine I have this code: var myFunc1 = function(event) { alert(1); } var myFunc2
Imagine I have a class Window with a member function show which causes the
Imagine I have a cell that I want to be red if the value
Imagine you have 2 databases : xpto & zpto. I want to do a
Imagine we have to sources to be requested by ajax. I want to perform
Here's a riddle. Imagine I have the following C++ function: template<uint8_t MASK> uint8_t Foo(uint8_t
imagine you have a function that creates/copies/moves files. [logic] For the case that a
Imagine I have a function that gives the transition probability of going from state

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.