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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:24:29+00:00 2026-06-04T06:24:29+00:00

I am trying to input a list into the function and it send me

  • 0

I am trying to input a list into the function and it send me a list with the first half of the elements taken away using f# with the below recursion but I keep running into a base case problem that I just cant figure out. any thoughts? I am using the second shadow list to count how far I need to go until I am half way into the list (by removing two elements at a time)

let rec dropHalf listToDrop shadowList = 
    match shadowList with
    | [] -> listToDrop
    | shadowHead2::shadowHead1::shadowTail -> if shadowTail.Length<=1 then listToDrop else 
                                    match listToDrop with 
                                    |[] -> listToDrop
                                    |listToDropHead::listToDropTail -> dropHalf listToDropTail shadowTail
  • 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-04T06:24:30+00:00Added an answer on June 4, 2026 at 6:24 am
    let rec dropHalf listToDrop shadowList = 
        match shadowList with
        | [] -> listToDrop
        | shadowHead2::[] -> listToDrop   (* odd number! *)
        | shadowHead1::shadowHead2::shadowTail -> 
            match listToDrop with 
            | [] -> listToDrop   (* should never happen? *)
            | listToDropHead::listToDropTail -> dropHalf listToDropTail shadowTail
    

    i’m afraid i don’t use F#, but it’s similar to ocaml, so hopefully the following is close to what you’re looking for (maybe the comment format has changed?!). the idea is that when you exhaust the shadow you’re done. your code was almost there, but the test for length on the shadow tail made no sense.

    i want to emphasize that this isn’t anything like anyone would write “in real life”, but it sounds like you’re battling with some weird requirements.

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

Sidebar

Related Questions

So I'm trying to take an input from a user using Scanner(System.in) but when
I am trying to read in a text input file that contains a list
Using VB.NET with ASP.NET and and ms-access 2003 data, I'm trying to input data
I’m trying to validate input by using egrep and regex.Here is the line from
Im trying to create a simple input box with form validation, but im not
How would I pass a list of values into a function, where the values
Im trying to send a array to my method with $.post() but Im kinda
I'm trying to create a function (in Python) that takes its input (a chemical
I have repetitive code that i am trying to refactor into a generic function
I have a list of rules for a given input file for my function.

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.