@@ -38,9 +38,8 @@ we hope to make learning FP easier.
3838Where applicable, this document uses terms defined in the [ Fantasy Land spec] ( https://github.com/fantasyland/fantasy-land )
3939and Rust programming language to give code examples.
4040
41- Also please be mindful that the project sometimes utilise FP related crates that are unfinished but contains
42- a specific typeclass or data type that is appropriate to give an explanation. Many of them are experimental and
43- are not suitable for production usage.
41+ The content of this section was drawn from [ Functional Programming Jargon in Javascript] ( https://github.com/hemanth/functional-programming-jargon ) and
42+ we sincerely appreciate them for providing the initial baseline.
4443
4544__ Table of Contents__
4645<!-- RM(noparent,notop) -->
@@ -1163,20 +1162,17 @@ assert_eq!(
11631162
11641163## Foldable
11651164
1166- An object that has a ` foldr/l ` function that can transform that object into some other type. We are using ` rats ` to give
1167- an example but the crate only implements ` fold_right ` .
1165+ An object that has a ` foldr/l ` function that can transform that object into some other type.
11681166
11691167` fold_right ` is equivalent to Fantasy Land Foldable's ` reduce ` , which goes like:
11701168
11711169` fantasy-land/reduce :: Foldable f => f a ~> ((b, a) -> b, b) -> b `
11721170
11731171``` rust
1174- use rats :: foldable :: Foldable ;
1175- use rats :: kind :: IntoKind ;
1176- use rats :: kinds :: VecKind ;
1172+ use fp_core :: foldable :: * ;
11771173
1178- let k = vec! [1 , 2 , 3 ]. into_kind () ;
1179- let result = VecKind :: fold_right ( k , 0 , | ( i , acc ) | i + acc );
1174+ let k = vec! [1 , 2 , 3 ];
1175+ let result = k . reduce ( 0 , | i , acc | i + acc );
11801176assert_eq! (result , 6 );
11811177```
11821178
0 commit comments