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

Haskell 3) Write a function that takes as input a string and a character and ret

ID: 3573827 • Letter: H

Question

Haskell

3) Write a function that takes as input a string and a character and returns True if the character is in the string.

4) Create a list of pairs, each consisting of a month index and corresponding string. Save to a variable "months".

5) Write a "dispMonths" function that takes as input an index argument and returns the corresponding string.

6) Call the dispMonth function with an index and display the month string that's returned in reverse.

7) Write a function that receives the first and last names of someone and returns the initials.

8) Write a list comprehension that produces a list of all numbers from 50 to 100 whose remainder when divided by 7 is 3.

9) Write a list comprehension that generates a list of all numbers from 1 to 20, except for the numbers 3, 14 and 19.

10) Write a function onlyUpper that takes as input a string and uses a list comprehension to filter everything except uppercase letters. Use a range as a predicate for the filter.

Explanation / Answer

3)there is a function strchr() included in sting.h library in C language.Its syntax is mentioned below

char *strchr(char *str, int ch);

It will search the string in str with the character mentioned in ch and returns the pointer if found otherwise returns null

bool chfound(char *str,char ch)

{

if(strch(str,ch)!=NULL)

return true;

else return false;

}

It can be also user defined as mentioned below

bool chfound(char *str,char ch)

{

i=0;

while(str[i]!='')

{

if (str[i]==ch)

return true;

else

return false;

}

i++;

}

4)struct months

{

int index;

char monthname[20];

};

5)char * dispmonths(int index)

{

if (index==1)

return("January");

else if (index==2)

return("February");

else if(index==3)

return("March");

else if(index==4)

return("April");

else if(index==5)

return("May");

else if(index==6)

return("June");

else if(index==7)

return("July");

else if(index==8)

return("August");

else if(index==9)

return("September");

else if(index==10)

return("October");

else if(index==11)

return("November");

else if(index==12)

return("December");

}

4)

5)def dispmonth(m)

return months.index[m];

6)def dispmonthrev(m)

return month.index[12-m];

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