SlideShare a Scribd company logo
1 of 2
Using Haskell, I need:
-- | Produce a list where sequences of repeated elements in the given list are replaced by just one
of the repeated element.
Where the result of the following compress statement
>>> compress [1,1,1,2,3,3,3,1,2,2,2,2]
results in:
-- [1,2,3,1,2]
Solution
Look the simple logic which we can apply to this problem is to find the repeating element in the
list unitl we didnt get the next distinct element
Once we get that element we stop comparing and stroes the index of that distinct element
and will add the repeating element (the element on which we wereworking beforing getting the
element) to the new compressed list
For example
list [1,1,1,1,2,2,3,3]
we wnt to compress the list
start with first element
ie 1
and keep itrerating until we get 2
once we traversed to this element we stop traversing stores the index of element 2
now we will add 1 in compressed list and will do the same with rest of the elements in the list
now next repeating element search will starts from the index whih we saves by getting the
dinsctint element

More Related Content

Similar to Using Haskell- I need- -- - Produce a list where sequences of repeated.docx

List Data Structure
List Data StructureList Data Structure
List Data StructureZidny Nafan
 
Built-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfBuilt-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfalivaisi1
 
Python PCEP Lists Collections of Data
Python PCEP Lists Collections of DataPython PCEP Lists Collections of Data
Python PCEP Lists Collections of DataIHTMINSTITUTE
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - JavaDrishti Bhalla
 
Searching Sorting
Searching SortingSearching Sorting
Searching Sortingguest2cb109
 
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap SortMohammed Hussein
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3infanciaj
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonAndrew Ferlitsch
 
Describe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfDescribe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfalshaikhkhanzariarts
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfAsst.prof M.Gokilavani
 
Implement a singly linked list as a functional data structure in Kot.pdf
Implement a singly linked list as a functional data structure in Kot.pdfImplement a singly linked list as a functional data structure in Kot.pdf
Implement a singly linked list as a functional data structure in Kot.pdfmaheshkumar12354
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdfAmuthachenthiruK
 
use python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfuse python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfsales223546
 

Similar to Using Haskell- I need- -- - Produce a list where sequences of repeated.docx (20)

Chapter 15 Lists
Chapter 15 ListsChapter 15 Lists
Chapter 15 Lists
 
List data structure
List data structure List data structure
List data structure
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Built-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdfBuilt-in Data Structures in python 3.pdf
Built-in Data Structures in python 3.pdf
 
Module III.pdf
Module III.pdfModule III.pdf
Module III.pdf
 
day 13.pptx
day 13.pptxday 13.pptx
day 13.pptx
 
Python PCEP Lists Collections of Data
Python PCEP Lists Collections of DataPython PCEP Lists Collections of Data
Python PCEP Lists Collections of Data
 
Collections Api - Java
Collections Api - JavaCollections Api - Java
Collections Api - Java
 
Searching Sorting
Searching SortingSearching Sorting
Searching Sorting
 
Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4Anton Kasyanov, Introduction to Python, Lecture4
Anton Kasyanov, Introduction to Python, Lecture4
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
data structures and algorithms Unit 3
data structures and algorithms Unit 3data structures and algorithms Unit 3
data structures and algorithms Unit 3
 
Whiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in PythonWhiteboarding Coding Challenges in Python
Whiteboarding Coding Challenges in Python
 
Describe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfDescribe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdf
 
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdfGE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
GE3151 PSPP UNIT IV QUESTION BANK.docx.pdf
 
Implement a singly linked list as a functional data structure in Kot.pdf
Implement a singly linked list as a functional data structure in Kot.pdfImplement a singly linked list as a functional data structure in Kot.pdf
Implement a singly linked list as a functional data structure in Kot.pdf
 
Chapter3.pptx
Chapter3.pptxChapter3.pptx
Chapter3.pptx
 
pyton Notes6
 pyton Notes6 pyton Notes6
pyton Notes6
 
Data Structures Design Notes.pdf
Data Structures Design Notes.pdfData Structures Design Notes.pdf
Data Structures Design Notes.pdf
 
use python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdfuse python Problem 2. Selection Sort In this problem you will implem.pdf
use python Problem 2. Selection Sort In this problem you will implem.pdf
 

More from slyndon

Use the Referraces to acce inportant val In the following net ionic eq.docx
Use the Referraces to acce inportant val In the following net ionic eq.docxUse the Referraces to acce inportant val In the following net ionic eq.docx
Use the Referraces to acce inportant val In the following net ionic eq.docxslyndon
 
Use the References to access importantv It is often possible to change.docx
Use the References to access importantv It is often possible to change.docxUse the References to access importantv It is often possible to change.docx
Use the References to access importantv It is often possible to change.docxslyndon
 
Use the following financial statements for Lake of Egypt Marina- Inc-.docx
Use the following financial statements for Lake of Egypt Marina- Inc-.docxUse the following financial statements for Lake of Egypt Marina- Inc-.docx
Use the following financial statements for Lake of Egypt Marina- Inc-.docxslyndon
 
Use SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxUse SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxslyndon
 
Using your own words and one complete sentence per term- define the fo.docx
Using your own words and one complete sentence per term- define the fo.docxUsing your own words and one complete sentence per term- define the fo.docx
Using your own words and one complete sentence per term- define the fo.docxslyndon
 
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docx
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docxUsing the method of 1-2 reactions balance the skeleton equation- I2 +.docx
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docxslyndon
 
Using the descriptions of the attributes given in the ERD below- provi.docx
Using the descriptions of the attributes given in the ERD below- provi.docxUsing the descriptions of the attributes given in the ERD below- provi.docx
Using the descriptions of the attributes given in the ERD below- provi.docxslyndon
 
Using the following definition for a Binary Tree Node - complete the f.docx
Using the following definition for a Binary Tree Node - complete the f.docxUsing the following definition for a Binary Tree Node - complete the f.docx
Using the following definition for a Binary Tree Node - complete the f.docxslyndon
 
using the concepts of bonding and polarity explaining the importance o.docx
using the concepts of bonding and polarity explaining the importance o.docxusing the concepts of bonding and polarity explaining the importance o.docx
using the concepts of bonding and polarity explaining the importance o.docxslyndon
 
Using the competing values framework as a point of reference- how woul.docx
Using the competing values framework as a point of reference- how woul.docxUsing the competing values framework as a point of reference- how woul.docx
Using the competing values framework as a point of reference- how woul.docxslyndon
 
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docx
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docxUsing jsfiddle-net In Javascript we are going to create a doubly Linke.docx
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docxslyndon
 
Using Java- Windows on the desktop are just one of many objects used i.docx
Using Java- Windows on the desktop are just one of many objects used i.docxUsing Java- Windows on the desktop are just one of many objects used i.docx
Using Java- Windows on the desktop are just one of many objects used i.docxslyndon
 
Using examples describe five major reasons for segregation of duties w.docx
Using examples describe five major reasons for segregation of duties w.docxUsing examples describe five major reasons for segregation of duties w.docx
Using examples describe five major reasons for segregation of duties w.docxslyndon
 
Using Java- Evaluate the expression- Be sure to list a value of approp.docx
Using Java- Evaluate the expression- Be sure to list a value of approp.docxUsing Java- Evaluate the expression- Be sure to list a value of approp.docx
Using Java- Evaluate the expression- Be sure to list a value of approp.docxslyndon
 
Using Java- code a dynamic Linear Quotient Hashing data structure that.docx
Using Java- code a dynamic Linear Quotient Hashing data structure that.docxUsing Java- code a dynamic Linear Quotient Hashing data structure that.docx
Using Java- code a dynamic Linear Quotient Hashing data structure that.docxslyndon
 
using C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docxusing C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docxslyndon
 
Using complete sentences- briefly answer the following- A) Accurately.docx
Using complete sentences- briefly answer the following- A) Accurately.docxUsing complete sentences- briefly answer the following- A) Accurately.docx
Using complete sentences- briefly answer the following- A) Accurately.docxslyndon
 
Using a practical example- what are the benefits and potential problem.docx
Using a practical example- what are the benefits and potential problem.docxUsing a practical example- what are the benefits and potential problem.docx
Using a practical example- what are the benefits and potential problem.docxslyndon
 
User Interface Engneering A company is designing a kiosk that can disp.docx
User Interface Engneering A company is designing a kiosk that can disp.docxUser Interface Engneering A company is designing a kiosk that can disp.docx
User Interface Engneering A company is designing a kiosk that can disp.docxslyndon
 
Use your own words to explain how the Black Death(1)- commodity prices.docx
Use your own words to explain how the Black Death(1)- commodity prices.docxUse your own words to explain how the Black Death(1)- commodity prices.docx
Use your own words to explain how the Black Death(1)- commodity prices.docxslyndon
 

More from slyndon (20)

Use the Referraces to acce inportant val In the following net ionic eq.docx
Use the Referraces to acce inportant val In the following net ionic eq.docxUse the Referraces to acce inportant val In the following net ionic eq.docx
Use the Referraces to acce inportant val In the following net ionic eq.docx
 
Use the References to access importantv It is often possible to change.docx
Use the References to access importantv It is often possible to change.docxUse the References to access importantv It is often possible to change.docx
Use the References to access importantv It is often possible to change.docx
 
Use the following financial statements for Lake of Egypt Marina- Inc-.docx
Use the following financial statements for Lake of Egypt Marina- Inc-.docxUse the following financial statements for Lake of Egypt Marina- Inc-.docx
Use the following financial statements for Lake of Egypt Marina- Inc-.docx
 
Use SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docxUse SQL to Create a table with at least 4 attributes one of which is t.docx
Use SQL to Create a table with at least 4 attributes one of which is t.docx
 
Using your own words and one complete sentence per term- define the fo.docx
Using your own words and one complete sentence per term- define the fo.docxUsing your own words and one complete sentence per term- define the fo.docx
Using your own words and one complete sentence per term- define the fo.docx
 
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docx
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docxUsing the method of 1-2 reactions balance the skeleton equation- I2 +.docx
Using the method of 1-2 reactions balance the skeleton equation- I2 +.docx
 
Using the descriptions of the attributes given in the ERD below- provi.docx
Using the descriptions of the attributes given in the ERD below- provi.docxUsing the descriptions of the attributes given in the ERD below- provi.docx
Using the descriptions of the attributes given in the ERD below- provi.docx
 
Using the following definition for a Binary Tree Node - complete the f.docx
Using the following definition for a Binary Tree Node - complete the f.docxUsing the following definition for a Binary Tree Node - complete the f.docx
Using the following definition for a Binary Tree Node - complete the f.docx
 
using the concepts of bonding and polarity explaining the importance o.docx
using the concepts of bonding and polarity explaining the importance o.docxusing the concepts of bonding and polarity explaining the importance o.docx
using the concepts of bonding and polarity explaining the importance o.docx
 
Using the competing values framework as a point of reference- how woul.docx
Using the competing values framework as a point of reference- how woul.docxUsing the competing values framework as a point of reference- how woul.docx
Using the competing values framework as a point of reference- how woul.docx
 
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docx
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docxUsing jsfiddle-net In Javascript we are going to create a doubly Linke.docx
Using jsfiddle-net In Javascript we are going to create a doubly Linke.docx
 
Using Java- Windows on the desktop are just one of many objects used i.docx
Using Java- Windows on the desktop are just one of many objects used i.docxUsing Java- Windows on the desktop are just one of many objects used i.docx
Using Java- Windows on the desktop are just one of many objects used i.docx
 
Using examples describe five major reasons for segregation of duties w.docx
Using examples describe five major reasons for segregation of duties w.docxUsing examples describe five major reasons for segregation of duties w.docx
Using examples describe five major reasons for segregation of duties w.docx
 
Using Java- Evaluate the expression- Be sure to list a value of approp.docx
Using Java- Evaluate the expression- Be sure to list a value of approp.docxUsing Java- Evaluate the expression- Be sure to list a value of approp.docx
Using Java- Evaluate the expression- Be sure to list a value of approp.docx
 
Using Java- code a dynamic Linear Quotient Hashing data structure that.docx
Using Java- code a dynamic Linear Quotient Hashing data structure that.docxUsing Java- code a dynamic Linear Quotient Hashing data structure that.docx
Using Java- code a dynamic Linear Quotient Hashing data structure that.docx
 
using C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docxusing C++ to Write a program to demonstrate an array of 10 elements an.docx
using C++ to Write a program to demonstrate an array of 10 elements an.docx
 
Using complete sentences- briefly answer the following- A) Accurately.docx
Using complete sentences- briefly answer the following- A) Accurately.docxUsing complete sentences- briefly answer the following- A) Accurately.docx
Using complete sentences- briefly answer the following- A) Accurately.docx
 
Using a practical example- what are the benefits and potential problem.docx
Using a practical example- what are the benefits and potential problem.docxUsing a practical example- what are the benefits and potential problem.docx
Using a practical example- what are the benefits and potential problem.docx
 
User Interface Engneering A company is designing a kiosk that can disp.docx
User Interface Engneering A company is designing a kiosk that can disp.docxUser Interface Engneering A company is designing a kiosk that can disp.docx
User Interface Engneering A company is designing a kiosk that can disp.docx
 
Use your own words to explain how the Black Death(1)- commodity prices.docx
Use your own words to explain how the Black Death(1)- commodity prices.docxUse your own words to explain how the Black Death(1)- commodity prices.docx
Use your own words to explain how the Black Death(1)- commodity prices.docx
 

Recently uploaded

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 

Recently uploaded (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 

Using Haskell- I need- -- - Produce a list where sequences of repeated.docx

  • 1. Using Haskell, I need: -- | Produce a list where sequences of repeated elements in the given list are replaced by just one of the repeated element. Where the result of the following compress statement >>> compress [1,1,1,2,3,3,3,1,2,2,2,2] results in: -- [1,2,3,1,2] Solution Look the simple logic which we can apply to this problem is to find the repeating element in the list unitl we didnt get the next distinct element Once we get that element we stop comparing and stroes the index of that distinct element and will add the repeating element (the element on which we wereworking beforing getting the element) to the new compressed list For example list [1,1,1,1,2,2,3,3] we wnt to compress the list start with first element ie 1 and keep itrerating until we get 2 once we traversed to this element we stop traversing stores the index of element 2
  • 2. now we will add 1 in compressed list and will do the same with rest of the elements in the list now next repeating element search will starts from the index whih we saves by getting the dinsctint element