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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:42:20+00:00 2026-06-12T18:42:20+00:00

This assignment is from Induction to Programming using sml 5.14 Here is my code

  • 0

This assignment is from Induction to Programming using sml 5.14

Here is my code but I get this message pattern matching is not exhaustive in in base case..

fun revrev [] = [[], []]
  | revrev [x::xs,y::ys] = revrev[ys@[y], xs @ [x]];


val test1revrev = revrev [[1, 2],[3, 4, 5]];

From valtest1 I want the output [[5, 4, 3], [2, 1]]

I fail to see why my function doesn’t work and need a little insight maybe.

For instance this works…

fun rev [] = []
  | rev (x::xs) = rev1 xs @ [x];

val test1rev = rev [1, 2, 3];
I get [3, 2, 1]
  • 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-12T18:42:21+00:00Added an answer on June 12, 2026 at 6:42 pm

    Pattern matching isn’t exhaustive because you only match either empty list or list with two elements.

    I think the intention of the exercise is to implement revrev based on rev which has been introduced before. Here are a few tips:

    • The base case is empty list. You simply return an empty list.
    • The inductive case matches a non-empty list x::xs. Similar to implementation of rev, you can call revrev on xs and put a transformation of x at the end. This time you need to use rev so that x itself is also reversed.

    EDIT:

    Your function doesn’t work in general cases. What I meant is the following skeleton:

    fun revrev [] = []
      | revrev (x::xs) = ...
    

    where x is also a list. Since this function is very similar to rev, I hope that you can fill in ... by yourself.

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

Sidebar

Related Questions

Below is selected code from one of 5 classes for this assignment. Each class
How to set entire HTML in MSHTML? I am trying using this assignment: (Document
I am getting a very strange error in my code. This assignment is for
This answer to this question is fine, but I'm looking for ADO.NET code to
This is an assignment question from school: Create a recursive method called toBinary that
I am doing this assignment, and there are some stuff (from start-up materials) that
So I'm almost done with this assignment but now I'm having difficulties again. When
We got this assignment from school to reproduce this example (created in Flash) into
I have this assignment where I must delete a chosen element from an array,
This is a homework assignment and my first experience using RegEx. I am starting

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.