Hi everyone, I need help in Haskell Please
1) Write a function that takes a two-operand integer function and a list of Ints, and applies the function to each in the list twice. it is OK to call the map in the function.
According to the question, a function that takes a two-operand integer function(here function 'mulList') and a list of 'Ints',
and applies the function to each in the list twice.
mulList is given as:
mulList :: Num a => [a] -> a -> [a]
mulList [] y = []
mulList (x:[]) y = (x * y):[]
mulList (x:xs) y = (x * y): (mulList xs y)
Map returns a list constructed by appling a function (the first argument) to all items in a list passed as the second argument.
Lets first create a function that applies to the list once.
import Data.Char
import Prelude hiding (map)
map :: (a -> b) -> [a] -> [b]
map _ [] = []
map f xs = [f x | x <- xs] //function f= mulList in our
case.
This function takes two arguments:
1.a function f which maps as to bs, and
2.a list xs of as. It returns a list of bs which are the results of applying f to every member of xs.
for example, map square [1,1,2,3,5,8] would yield the list [1,1,4,9,25,64].
To apply the function to each in the list element twice
just do the following
f w = concat (map mulList (mulList w))
OR
import Control.Monad; f = mulList >=> mulList
Hope this may help you
Thank you ??
Hi everyone, I need help in Haskell Please 1) Write a function that takes a two-operand...
Hi everyone, I need help in Haskell, please. Write a Haskell function that takes an Int i as its only parameter and uses a list comprehension to caclulate m(i) = 1 + 1/2 + 1/3, ... + 1/i
Hi everyone, I need help In Haskell Coding. Please code in Haskell, Regards 1) Write a function that takes a list of tuples of three integers each and returns a list consisting of just the tuples that are Pythagorean triples. instead of using a list comprehension, use lambda expression and a function that tests one tuple and returns a Bool. As long as the lambda expression is correct, it is OK to make this simpler by having the lambda calls...
Hi everyone, I need help in Haskell coding to please only Haskell code, Regards Consider this function: applyThrice f x = f (f (f x)) this function takes a unary function: for example: >applyThrice (+2) 2 8 use ., the function composition operator, and/or $, the function application operator, to make this function more readable
Hi Every one, hope all is well. I need help in Using Haskell coding Please, please read the instructon very carefully to: (in Syntax Code please) NOTE: function headers (for example, for the area-of-a-rectangle function, do not need to write area :: Int-> Int-> Int at the top of your function). You may use the :{ ... :} syntax to write multi-line functions in prelude Haskell platform. Write a function that takes three numbers, a b, and c, and returns...
Hi, I need help with Python Dictionaries please. Question: Write a function named "get_stat" that takes a key-value store as a parameter with strings as keys and integers as values. The keys include "Strength", "Constitution", "Defense", "Dexterity", "Intelligence", "Charisma", "Willpower", and "Luck" and each value is an integer between 0 and 255. This function should return the value for the "Strength" stat. Thanks!
Haskell Function program Write a function negateOdds that takes a list of integers and returns a list of integers with all of the odd integers negated. negateOdds :: [Integer] -> [Integer] example: [1,2,3,4,5] should return [-1,2,-3,4,-5]
Hi, I need help with Javascript please. Question: Write a function named "tweets" that takes a string as a parameter and returns the number of tweets required to tweet the input to the world. Note: The maximum length for a single tweet is 280 characters. Thanks!
Hi, I need help with Python Dictionaries please. Question: Write a function named "add_key_value" that takes a key-value store as a parameter with strings as keys and integers as values. The function will add a key-value pair to the input store with a key of "slam" and a value of 39. There is no need to return any value. Thanks!
hi everyone, this is a biochemistry question I need help with
explaining. Please show/explain your steps or work,
thank you in advance!
B) Outline a known moonlighting function of one of the enzymes of the TCA. C) Outline how the TCA is regulated.
Please I need help with this. Thank you
Write the function cycle of type 'a list *int-> 'a list that takes a list and an integer n as input and returns the same list, but with the first element cycled to the end of the list n times. For example, cycle ([1,2,3,4,5,6], 2) should return [3,4,5,6,1,2)]. You can make use of the cycle 1 function given below as a helper function. fun cycle1 list- tl list hd list]: