here the function multiplies the items in the list using the CPS style
mlist xx k = aux xx k where aux [] nk = nk 1 aux (0:xs) nk = k 0 aux (x:xs) nk = aux xs $ \v -> mul x v nk
what if i change 'k' to 'nk' in the expression aux (0: xs) nk = k 0 , what is the difference between the two?
kis always the original continuation passed in mlist, while for the list [1, 0] nkin this case it will be \v -> mul 1 v k(from the third case aux).
k
mlist
nk
\v -> mul 1 v k
aux
, mul mul x y k = k $ x*y, , y 0. ( ).
mul
mul x y k = k $ x*y
y
, " " , , - "" .
Source: https://habr.com/ru/post/1753811/More articles:Как определить счетчики уравнений и подсекций в LaTeX? - latexHow to define two counters in LaTeX? - latexEnter a column with a table with a table - ruby-on-railsWill the JVM extend to handle generics? - javaHTTP response 411 Required length, Http Client 4.0.1 Android - androidНеправильно ли было установить WITH PERMISSION_SET = UNSAFE в SQL 2005? - c#Creating Maven Multi-Module Projects in Eclipse - eclipseHow to pass a method pointer as a template parameter - c ++How to attach a text file stored locally in the application directory - androidThe task of calculating the maximum number and splitting sets using PHP - setAll Articles