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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:15:27+00:00 2026-06-04T00:15:27+00:00

I am trying to learn Haskell from Haskell Road to Logic and came across

  • 0

I am trying to learn Haskell from Haskell Road to Logic
and came across this example:

    mnmInt :: [Int] -> Int
    mnmInt [] = error "empty list"·
    mnmInt [x] = x
    mnmInt (x:xs) = min x (mnmInt xs)

I understand the functions takes a list of Int –
Checks if empty
if not
checks if it’s a list with 1 int if so return x
if not
plug mnmInt with xs parameter to min.

how does it reach the base case? what does the xs stand for?

min implementation:

   min' :: Int -> Int -> Int
   min' x y | x <= y    = x
            | otherwise = y

doesn’t take an array.

  • 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-04T00:15:28+00:00Added an answer on June 4, 2026 at 12:15 am

    (x:xs) is pattern matching syntax. Pattern matching lets you “destructure” data types and bind them to names. In this case x is the head of the list, and xs is the tail. min' doesn’t need to take a list because x is the head of the list, not a list itself.

    min' itself finds the minimum value between two Ints, mnmInt will eventually expand out to something like (min' 1 (min' 2 (min' 3 4))) if you pass in a list that looks like [1,2,3,4].

    This is easy to see if you evaluate the code by hand, which I highly suggest you try. Remember, (x:xs) is two names, which are the head and tail of the list. You might want to play around with constructing lists using :

    Here is an example that shows how pattern matching relates to code flow.

    foo (x:y:[]) = "two"
    foo ([]) = "none"
    foo (_) = "some other value"
    

    if you call foo [1,2] it will output “two”, if you do foo [1,2,3] it will give you “some other value”, and if you do foo [] it will return "none"

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

Sidebar

Related Questions

I'm trying to compile this function from Learn You a Haskell for Great Good
I'm trying to go through the YesNo example from Learn You a Haskell for
I'm trying learn Python (3 to be more specific) and I'm getting this error:
Trying to implement, in Scala, the following Haskell function (from Learn You a Haskell...)
coming from the Ocaml community, I'm trying to learn a bit of Haskell. The
I’m trying to learn Haskell and I was trying to create a function that
I've recently been trying to learn me a Haskell, and I'd like to create
Trying to learn a bit about PDO and is going through this tutorial .
I´m trying to learn C#, coming from a Python/PHP background, and I´m trying to
I've recently caught the FP bug (trying to learn Haskell), and I've been really

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.