This has to be answered in Haskell. What can I input into the black screen so th
ID: 3750753 • Letter: T
Question
This has to be answered in Haskell. What can I input into the black screen so that all 6 equations can be answered on the right?
Keep elements at even indices Wite a recursive function atEvenIndices that takes a list and returns a list that retains the elements at positions 0,2,4, etc-atemating ghciy atEvenIndices [1..1] s possibe [1,3,5,7,9 ghci> atEvenIndices [Alice", "Bob", "Carl" s possible Alice","Carl"] ghcl atEvenIndices "university ulest See the test case names tor more examples. Hint: This function actualy has two base cases the empty list, and the list contaning just single element Automated Results EvenindiceshsO New 1 module EvenIndices where )( Full Screen Not Run otEvenindices university er Not Run Not venindices 11,3013 11357.9 Not Run ME venindices [1 1 1 Not Not Help & Support
Explanation / Answer
Here is the code in Haskell (Replace f with Input list and run the statement in main function):
f l=[x|p<-[even],(i,x)<-zip[0..]l,p i]
main = print $ f [1..9]
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.