Information

Deadline Keine Frist
Abgabenlimit No limitation

Einloggen

[3.12] MapAccumL [Suppl.]

Définissez les fonctions mapAccumL, mapAccumLTerm et mapAccumLImpl qui sont un mix de map et de foldl : elles appliquent une fonction à tous les éléments d'une liste tout en transportant un accumulateur de gauche à droite, et renvoient la liste ainsi que l'accumulateur.

\begin{align*} & \text{Nom (explicite simple)} & & \texttt{mapAccumL f acc list} \\ & \text{Nom (explicite terminale)} & & \texttt{mapAccumLTerm f acc list} \\ & \text{Nom (implicite)} & & \texttt{mapAccumLImpl f acc list} \\ & \text{Type} & & \texttt{(acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])} \\ & \text{Conditions} & & - \\ & \text{Résultat} & & \text{applique la fonction } \texttt{f} \text{ à tous les éléments de } \texttt{list} \text{ tout en transportant un accumulateur (} \texttt{acc} \text{) de gauche à droite, et renvoie la liste ainsi que l'accumulateur.} \end{align*}
Équivalent Python (Cliquez ici)

Le code