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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:04:38+00:00 2026-06-13T03:04:38+00:00

Suppose I have a function that returns a certain value when it satisfies a

  • 0

Suppose I have a function that returns a certain value when it satisfies a given condition and does not return any value when the condition is not satisfied.

e.g.

fun foo(n)= if n< 100000 then n else (something like exit function. We have it in other programming languages. Do we have something like that here?)

I initially wanted to write () but it says mismatch in two conditions of if or something.

Becoming more explicit, I want to write a function that takes a number, any number and combines to a list if it is valid integer and disregards it if it is not integer.

  • 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-13T03:04:40+00:00Added an answer on June 13, 2026 at 3:04 am

    In SML a function always has to return a value¹. One way to represent a function that may or may not have a useful result would be using the OPTION type. Using OPTION your function would return SOME value if it has something useful to return, or NONE if it does not.

    For your particular use-case another alternative would be to take the list as a second argument and then either return the result prepended to the list or the list unchanged.

    ¹ In fact I’m not aware of any language where a non-void function is allowed to not return a value (without invoking undefined behavior). In some languages you can return null in place of a proper return value, but in most languages that isn’t allowed for functions with return type int. Either way SML doesn’t have a null value.

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

Sidebar

Related Questions

Suppose I have a function that returns a closure: sub generator { my $resource
Is there a standard function that returns the position (not value) of the maximum
Suppose I have a SQL function that returns a table and I get the
Suppose I have a SQL function that returns a table and I get the
Suppose I have a function f that takes a vector v and returns a
Suppose I have a PL/SQL function that selects one value from a table. If
Suppose i have a function that returns an important result and several unimportant results.
Suppose that you have a function f: List a -> a such that f
Suppose that in the main I have a function a : a(c); and c
Suppose I have a function void myFun(int*) In C++ what exactly does the following

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.