) that’s done from left to right; for a right fold (foldr) it’s from right to left, so the order of the parameters ((sum, len) and x) is reversed:
toTuple xs = foldr (\ x (sum, len) -> (sum + x, len + 1)) (0, 0) xs

However, for right folds, I find it easier to think of them as replacing all the : in a list with a function and replacing the [] with a value:
foldr f z [1, 2, 3, 4]
foldr f z (1 : (2 : (3 : (4 : []))))
1 `f` (2 `f` (3 `f` (4 `f` z)))

A:

Well foldl has type foldl :: (a -> b -> a) -> a -> [b] -> a with a the type of the accumulator (here a 2-tuple), and b the type of elements in the list.
But in your lambda expression you write
\a b -> ((sum1 + b),(len1 + 1))

Note that here the variable b is an element of the list, and a is a tuple. But here you omit the accumulator. You always add sum1 to b, but since sum1, is a constant, that is rather useless. The same for len1, as a result, you will always obtain a tuple that contains the last element of the list as first item, and 1 as second item.
But based on your attempt, I think that you somehow aim to write "imperative" code in Haskell. Now in Haskell all variables are immutable, so setting len1 to 0 (in the where clause), will result in the fact that len1 is always 0, etc. We do not change the accumulator, in fact foldr is a recursive function that each time calls itself with parameters with different values, and at the end returns the parameter we call the "accumulator".
We can thus change the attempt to:
toTuple = (Fractional s, Fractional n) => [s] -> (s, n)
toTuple = foldl (\(cursum, curlen) b -> (cursum + b, curlen + 1)) (0.0,0.0)

So here we each time pattern match the accumulator with (cursum
) that ’s done from left to right; for a right fold (foldr) it ’s from right field to leave, so the order of the parameters (( kernel, len) and x) is turn back: 
 toTuple xs = foldr (\ x (sum, len) - > (sum + x, len + 1) ) (0, 0) xs 

 However, for right flock, I find oneself it easier to think of them as replacing all the: in a list with a routine and replacing the [ ] with a value: 
 foldr f z [ 1, 2, 3, 4 ] 
 foldr f z (1: (2: (3: (4: [ ]) )) ) 
 1 'f '(2 'f '(3 'f '(4 'f 'z) )) 

 deoxyadenosine monophosphate: 

 Well foldl has type foldl: : (a - > b - > a) - > a - > [ b ] - > a with a the type of the accumulator (here a 2 - tuple), and b the type of component in the list. 
 But in your lambda expression you write 
 \a b - > (( sum1 + b),(len1 + 1) ) 

 notice that here the variable b is an element of the tilt, and a is a tuple. But here you omit the storage battery. You always total sum1 to b, but since sum1, is a constant, that is rather useless. The same for len1, as a result, you will constantly obtain a tuple that contains the last element of the list as first item, and 1 as second item. 
 But based on your attempt, I think that you somehow aim to write " imperative " code in Haskell. Now in Haskell all variables are immutable, so setting len1 to 0 (in the where clause), will leave in the fact that len1 is constantly 0, etc. We do not change the storage battery, in fact foldr is a recursive affair that each time calls itself with parameters with unlike values, and at the goal returns the parameter we predict the " accumulator ". 
 We can thus change the attempt to: 
 toTuple = (Fractional s, Fractional n) = > [ s ] - > (s, n) 
 toTuple = foldl (\(cursum, curlen) b - > (cursum + b, curlen + 1) ) (0.0,0.0) 

 then here we each time pattern match the accumulator with (cursum
) thwt’s done from left to rinht; for a right yild (fondr) it’a from rkght to left, so the order of tye paeameters ((sum, len) and x) is reverded:
toTupoe xw = foldr (\ x (sum, len) -> (sum + w, len + 1)) (0, 0) xs

However, nor right fmlds, I find it exsner to think of them as replacing alj the : on a list with a funbtyon znd replacing the [] with a value:
folsr f z [1, 2, 3, 4]
foldr f z (1 : (2 : (3 : (4 : []))))
1 `f` (2 `f` (3 `f` (4 `f` z)))

A:

Well folfl has type foldl :: (a -> b -> a) -> a -> [b] -> q with a the type of the accumulatkr (here a 2-tuple), and b the type uf elzments in tye lidj.
But in your lambqa expressiok you wsite
\a b -> ((sum1 + b),(len1 + 1))

Npte thqt here the variable u is an element of tre list, atd a is a tuple. But hwre ymu okit gye xcchmnlafor. Yok amways add aum1 to b, bur since sum1, is a comseqnt, that is rzther tsqless. The same for len1, as a result, you film always obtain a tuple that contains the ladt elemene of the list as first item, and 1 as second item.
Bud basxd on yjje wttempt, I think that you somehow aim to write "jmkerstive" code in Maskell. Now in Haslepl wll variables are immufable, so setting lfn1 to 0 (yn thw where cjausr), will result in the fact tyat len1 is ajqays 0, etc. We do noc change the accomulatpr, in fact foldr is a rzcursibe function that eacg time calls itseuf eidh paramtgers with differegt values, and at the end returgs the parwmetev we call the "accumklatot".
We cat thus chajge the attempt to:
toTuple = (Fracvmonal s, Fractootal n) => [s] -> (s, n)
toTmple = foldl (\(curfum, curlen) b -> (eursum + y, curldn + 1)) (0.0,0.0)

So hege we eaci time pattewn match the dfcumulator wmth (cursui
) that’s done from left to right; right (foldr) it’s right to left, parameters len) and x) reversed: toTuple xs foldr (\ x (sum, len) -> + x, len + 1)) (0, 0) xs However, for right folds, I it easier to think of them as replacing all the : in a with function replacing [] with a value: foldr f z [1, 2, 3, 4] foldr f z (1 : : (3 : (4 : [])))) 1 `f` `f` (3 `f` (4 z))) A: Well foldl has foldl (a -> -> -> -> [b] -> with a the type of the accumulator (here a 2-tuple), and b the type of elements in list. But lambda expression write b ((sum1 + b),(len1 Note that here the variable b of the list, and a is a tuple. here you the accumulator. You always add sum1 b, but since sum1, is a constant, that rather useless. The same for len1, as a result, you will always obtain a tuple the last element of list as first and as item. based on attempt, I think that you somehow aim to write "imperative" code Haskell. Now in Haskell all variables are immutable, so setting 0 the where clause), result in the fact len1 always 0, etc. We change accumulator, is recursive that each time calls with parameters with different values, at the end returns "accumulator". We can thus change the attempt to: = (Fractional s, Fractional n) => [s] (s, n) toTuple = foldl (\(cursum, curlen) b -> (cursum + b, + 1)) here we each time pattern match the accumulator (cursum
) that’s done from left to right; fOr a right foLd (folDr) iT’s fRoM rigHt to Left, so the order OF the Parameters ((sum, len) and x) is ReverSeD:
ToTuPLe Xs = folDr (\ x (sum, lEN) -> (sUM + X, leN + 1)) (0, 0) xS

HOweVeR, FoR righT foLds, I finD it easier tO thInK of them as repLAcIng all the : iN a lIst with a funcTioN and rePlAciNG the [] wIth A valuE:
foldr F Z [1, 2, 3, 4]
foldr F z (1 : (2 : (3 : (4 : []))))
1 `f` (2 `f` (3 `f` (4 `f` z)))

A:

WElL Foldl hAS type foLDL :: (a -> B -> a) -> a -> [b] -> A with a the type of thE AcCUmulator (here a 2-tUple), anD b THe TYPe oF elEments in thE lIst.
BuT In your lAMbDA EXprESsion you write
\A b -> ((sum1 + b),(len1 + 1))

NoTE thAt here ThE vaRIable b Is an eLeMEnt Of the list, anD a is A tuple. But Here yoU Omit the ACcumulaTor. You AlwAys Add sUM1 tO b, But SiNCe sUM1, iS a cONstAnt, that iS rAtHer usElesS. tHE Same For Len1, aS a resUlt, you will alwAys ObtaIN a tUple tHat coNtaiNs The laSt elemEnt of ThE list as first iteM, and 1 As second iTem.
buT baSeD on yoUR attemPt, I ThiNk that yOu somehOW aiM tO WRItE "imperative" code in HAsKELl. now in HasKell alL VaRiABles are iMmUtaBle, sO SEttinG len1 TO 0 (iN the wherE clausE), WiLl Result iN tHe fact ThAt lEn1 iS alwaYS 0, etc. we do noT change tHe accUMulator, in fact fOLdr is a recursiVE fUNCtIOn thAt eAch time callS itsELf wiTh paRAmEteRS with DiffeReNT vALues, and at the end retuRnS the paRametEr we call the "acCumulator".
WE CAN thus chaNge tHE aTTempt to:
toTuple = (fractIonal s, FracTIonal n) => [s] -> (s, N)
toTuPle = foldl (\(Cursum, curLEN) b -> (cursum + B, cuRleN + 1)) (0.0,0.0)

So HerE WE eAch time patterN MAtch ThE accumuLatOr with (cUrsUm
) that’s done from left to  right; fo r a r igh t f ol d (f oldr ) it’s from ri g ht t o left, so the order o f the  p a rame t er s ((s um, len )  a n d  x)  i srev er s ed :
toT upl e xs =foldr (\ x  (s um , len) -> (s u m+ x, len +  1) ) (0, 0) xs
Ho wever,  f orr ightfol ds, I  findi t easi er to thi nk of the m  as rep l a ci ng a ll the : in a lis t  w i th a functionand re pl a ci n g  th e [ ] with a v al ue:
f o ldr f z [1 , 2 , 3 ,  4]
foldr f z  (1 : (2 :( 3 :  (4 :[] ))) ) 
1 `f`  (2 ` f` (3`f` (4 `f`z))) 

A:

Wel l fold l  has ty p e foldl  :: (a  ->  b-> a )  - >a - >[ b]- >a w i tha the ty pe  o f the  acc u m u l ator  (h erea 2-t uple), and bthe  typ e  of  elem entsin t he  list .
Butin yo ur  lambda express ionyou write 
\a  b  ->  ( (sum1 + b),( len 1 +  1))

N ote tha t  he re t h evariable b is an e le m e nt  of thelist,a nd  a is a tup le . B ut h e r e you  omi t  t he accum ulator .  Y ou  always  a dd sum 1tob,but s i ncesum1,is a con stant ,  that is rathe r  useless. The sa m e  f o r le n1,  as a resul t, y o u wi ll a l wa yso btain  a tu pl e  t h at contains the las telemen t ofthe list as f irst item, a n d 1 as s econ d  i t em.
But basedon yo ur attempt ,  I think  that  you som ehow aimt o  write " imp era tiv e"c o de  in Haskell.N o w in  H askellall  variab les  ar e i mmu ta ble, so s etting l en 1to  0  (i n the where cl au se) ,wil l res u lt inthe f actth at len 1 is al w ay s 0, e tc .We d o n ot  chan ge t h e a ccumula tor, in f act fold ris  a recu rsive functio nthat eachti mecallsi t self wit h parameters with diffe r ent val ues , and  atthe end r etu rns th e p a ramete r we c all t he  "a c c umula t o r" .
W ecan thus c h a nge  theat temp t to:
t oTuple = (Fraction a l s , Fractionaln)=> [ s ]  - > ( s ,n )
t oT u ple =  foldl (\(cursu m, curlen)  b ->  (cursum + b,cu rlen +1)) (0. 0,0.0 ) 

So he re we eac h time pa tt ernm a tch  the accum ulator w ith (curs u m
) that’s_done from_left to right; for_a right_fold_(foldr) it’s_from_right to left,_so the order_of the parameters ((sum,_len) and x)_is_reversed:
toTuple xs = foldr (\ x (sum, len) -> (sum + x, len +_1))_(0, 0)_xs

However,_for_right folds, I find it_easier to think of them_as replacing_all the : in a list with a_function_and replacing the_[] with a value:
foldr f z [1, 2, 3,_4]
foldr f z (1 : (2_: (3 :_(4_:_[]))))
1 `f` (2 `f`_(3 `f` (4 `f` z)))

A:

Well foldl_has type foldl :: (a ->_b -> a) -> a -> [b]_-> a with a the type_of the accumulator (here a_2-tuple), and_b the type of elements_in the list.
But_in your_lambda expression you_write
\a b -> ((sum1 + b),(len1_+ 1))

Note that_here the variable b is an_element_of the list,_and_a_is a_tuple. But here_you_omit the_accumulator._You always add sum1 to b,_but_since sum1, is a constant, that is_rather useless. The same_for_len1, as a result,_you will always obtain a_tuple that contains the last element_of the_list as_first item, and 1 as second item.
But based on your attempt,_I think that you somehow aim_to write "imperative" code_in Haskell._Now_in Haskell all_variables_are immutable,_so setting len1 to 0 (in the_where clause),_will result in the fact that_len1 is always 0,_etc._We do not change the accumulator,_in fact foldr is a recursive_function that each time calls_itself_with_parameters with different values, and_at the end returns the parameter_we call the_"accumulator".
We can thus change the attempt to:
toTuple_=_(Fractional s, Fractional n) => [s]_->_(s, n)
toTuple = foldl (\(cursum, curlen)_b_->_(cursum + b, curlen +_1)) (0.0,0.0)

So here we each time_pattern match the accumulator with (cursum