Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This has to be in haskell. What do I enter into the black screen so that all 6 e

ID: 3750742 • Letter: T

Question


This has to be in haskell. What do I enter into the black screen so that all 6 equations pass on the right? Slice a list between two indices We learned about built-in functions take and drop Use them to write a function slice i k xs, where i and k are xs is a list It should return a list out of bounds, make sure it returns an empty list and drop Use them to wite a function slice i k xs, where i and k are integer postions and contaning the elements of xs between postions i and k (inctuding , but excluding k) itfk

Explanation / Answer

//using drop and dropright
def Slice(xs:Array[int],i:int,k:int) Array[int]:{
var n=xs.length;
xs=xs.drop(i-1);
xs=xs.dropRight(n-k);
return xs:Array[int];
}

//using take and drop
def Slice(xs:Array[int],i:int,k:int) Array[int]:{
var n=k-i;
xs=xs.drop(i-1);
xs=xs.take(n);
return xs:Array[int];
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote