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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:18:54+00:00 2026-05-26T03:18:54+00:00

I have a list of lists, and a function that returns the list with

  • 0

I have a list of lists, and a function that returns the list with the most items:

extract ::[Plateau]->Plateau

extract(x:xs) 
  |x==maximumBy(compare `on` length)(x:xs)=x 
  |otherwise = extract(xs)
extract []=[""]

Now I need a function to take the same [Plateau] and return a new [Plateau] that has the previous largest removed:

prune::[Plateau]->[Plateau]
prune(x:xs)
  |x < (maximumBy(compare `on` length)(x:xs)=x : prune (xs)
  |x>=maximumBy(compare `on` length)(x:xs)=[]
prune [] = [] 

I also call prune with a sortBy as to make sure the largest list is last:

(extract . prune) (sortBy(compare `on` length)(plateaus))

This starts out to work correctly. my List plateaus looks like:

plateaus = ["01000"], ["01010", "11010", "10010"] ["00101"], ["01101", "01001"]]

here it is sorted:

 [["01000"], ["00101"], ["01101", "01001"], ["01010", "11010", "10010"]]

Now, my function prune is returning a list of

[["01000"], ["00101"]]

that tells me, for some reason Haskell thinks

["01101", "01001"] >= ["01010", "11010", "10010"]

When I can clearly see that 2 >= 3 is not true.

Why is this?

  • 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-05-26T03:18:54+00:00Added an answer on May 26, 2026 at 3:18 am

    List comparison is lexicographic, not by length. So you get the result you see because “01101” >= “01010”, which in turn is for the same reason – the first two characters of the two strings are equal and the third character of the first is greater than the third character of the second.

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

Sidebar

Related Questions

We have a table value function that returns a list of people you may
I have a function, that returns the next higher value of a Dictionary-Keys-List compared
I have a function that returns a list via yield. I use this function
I have a function that returns a list of email addresses from a SQL
I want to have a function that will return the reverse of a list
I have a function that gets x(a value) and xs(a list) and removes all
I have a function that uses Pattern#compile and a Matcher to search a list
I have a very simple function that takes a list of comma separated (x,y)
I have a function that presents the user a combo-box. def select_interface(interfaces) list_box :items
I would like to have a function that modifies some variable list of parameters

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.