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
The Haskell language provides us with 2 operators, the function
composition operator (.) and the application operator ($).
The two operators can be understood with this simple schematic:
For infix operator $, the left operand should be a function of
the type a -> b, the right operand becomes the value on which
the function is to be applied. In laymen's terms, if a then get the
results for b.
For . both the operands are functions with their return value being
a function too. We can use composition to chain many functions to
get a final function which accepts the operand, this way, the final
function obtained can be used as the left operand for the
application operator $.
Now to composite the given function we can proceed as
follows:
First looking at the innermost f x:
Here we have a function f which accepts one argument. Since we
don't know the type let's assume x has type 'a', so a: x::a.
Thus we can say f accepts a value of type 'a', a: f :: a -> _,
let this new unknown type be 'b', thus, we arrive at -
b: f :: a -> b.
So f x would be of type b.
But, we have f(f x) and the input for f is of type ' a'. Thus we
can conclude that a and b are actually the same type.
So, we get f:: a -> a. The same can be said for f(f(f x ).
Concurring to this we can say that our functions accept several
parameters despite each function actually taking only one parameter
and returning partially applied functions until we reach the final
function that returns a solid value.
Thus we can rearrange our function for composition as :
applyThrice f = f . f . f $ x
Hi everyone, I need help in Haskell coding to please only Haskell code, Regards Consider this...
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, 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 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.
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 some help writing matlab code for the conversion of a greyscale image to 8-bit per pixel greyscale, using block truncation coding. Can someone please provide some code for me to use?
Programming Paradigms , using Haskell !!!! I need help on this problem , Intersection of list of list HASKELL I need to use my own definition for intersection . Its my homework assignment. example like : intersection [ [2, 8, 6, 5, 8, 8, 8], [8, 8, 1, 1, 4, 8], [3, 3, 8, 10, 8, 10, 8, 7, 8, 8, 3]] Output: [8, 8, 8] intersection [ [1, 2, 3, 4], [5, 6, 7], [8], [9, 10]] Output: [...
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.
Hi I need help on C++ coding hw Q! thank you!
Q4 6 Points List 3 things that are wrong with the following code: int *n - new int; // line 1 bool x - false; // line 2 bool *b; // line 3 int *p - n; // line 4 *b- true; // line 5 delete ni // line 6 b- &x; // line 7 delete bi // line 8 delete : // line 9 Please reference the line...
Hi guys, i need the coding, please help me. (Must using
KEIL uversion software). TQ
Write a coding for Counter to count from 00 until 99 (in decimal). Display the result at 2 BCD 7- segment attached to address 0x20000000 and 0x20000001.
Hi everyone! I need help on my Java assignment. I need to create a method that is called sumIt that will sum two values and will return the value.It should also invoke cubeIt from the sum of the two values. I need to change the currecnt program that I have to make it input two values from the console. The method has to be called sumIt and will return to the sum that will produce the cube of the sum...