@@ -189,8 +189,8 @@ pub fn is_empty(list: List(a)) -> Bool {
189
189
pub fn contains ( list : List ( a) , any elem : a) -> Bool {
190
190
case list {
191
191
[ ] -> False
192
- [ head , .. ] if head == elem -> True
193
- [ _ , .. tail ] -> contains ( tail , elem )
192
+ [ first , .. ] if first == elem -> True
193
+ [ _ , .. rest ] -> contains ( rest , elem )
194
194
}
195
195
}
196
196
@@ -624,7 +624,7 @@ pub fn prepend(to list: List(a), this item: a) -> List(a) {
624
624
fn reverse_and_prepend ( list prefix : List ( a) , to suffix : List ( a) ) -> List ( a) {
625
625
case prefix {
626
626
[ ] -> suffix
627
- [ head , .. tail ] -> reverse_and_prepend ( list : tail , to : [ head , .. suffix ] )
627
+ [ first , .. rest ] -> reverse_and_prepend ( list : rest , to : [ first , .. suffix ] )
628
628
}
629
629
}
630
630
@@ -903,9 +903,9 @@ pub fn find_map(
903
903
pub fn all ( in list : List ( a) , satisfying predicate : fn ( a) -> Bool ) -> Bool {
904
904
case list {
905
905
[ ] -> True
906
- [ head , .. tail ] ->
907
- case predicate ( head ) {
908
- True -> all ( tail , predicate )
906
+ [ first , .. rest ] ->
907
+ case predicate ( first ) {
908
+ True -> all ( rest , predicate )
909
909
False -> False
910
910
}
911
911
}
@@ -940,10 +940,10 @@ pub fn all(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool {
940
940
pub fn any ( in list : List ( a) , satisfying predicate : fn ( a) -> Bool ) -> Bool {
941
941
case list {
942
942
[ ] -> False
943
- [ head , .. tail ] ->
944
- case predicate ( head ) {
943
+ [ first , .. rest ] ->
944
+ case predicate ( first ) {
945
945
True -> True
946
- False -> any ( tail , predicate )
946
+ False -> any ( rest , predicate )
947
947
}
948
948
}
949
949
}
@@ -1732,9 +1732,9 @@ fn do_take_while(
1732
1732
) -> List ( a) {
1733
1733
case list {
1734
1734
[ ] -> reverse ( acc )
1735
- [ head , .. tail ] ->
1736
- case predicate ( head ) {
1737
- True -> do_take_while ( tail , predicate , [ head , .. acc ] )
1735
+ [ first , .. rest ] ->
1736
+ case predicate ( first ) {
1737
+ True -> do_take_while ( rest , predicate , [ first , .. acc ] )
1738
1738
False -> reverse ( acc )
1739
1739
}
1740
1740
}
@@ -1764,14 +1764,14 @@ fn do_chunk(
1764
1764
acc : List ( List ( a) ) ,
1765
1765
) -> List ( List ( a) ) {
1766
1766
case list {
1767
- [ head , .. tail ] -> {
1768
- let key = f ( head )
1767
+ [ first , .. rest ] -> {
1768
+ let key = f ( first )
1769
1769
case key == previous_key {
1770
1770
False -> {
1771
1771
let new_acc = [ reverse ( current_chunk ) , .. acc ]
1772
- do_chunk ( tail , f , key , [ head ] , new_acc )
1772
+ do_chunk ( rest , f , key , [ first ] , new_acc )
1773
1773
}
1774
- _true -> do_chunk ( tail , f , key , [ head , .. current_chunk ] , acc )
1774
+ _true -> do_chunk ( rest , f , key , [ first , .. current_chunk ] , acc )
1775
1775
}
1776
1776
}
1777
1777
_empty -> reverse ( [ reverse ( current_chunk ) , .. acc ] )
@@ -1791,7 +1791,7 @@ fn do_chunk(
1791
1791
pub fn chunk ( in list : List ( a) , by f : fn ( a) -> key) -> List ( List ( a) ) {
1792
1792
case list {
1793
1793
[ ] -> [ ]
1794
- [ head , .. tail ] -> do_chunk ( tail , f , f ( head ) , [ head ] , [ ] )
1794
+ [ first , .. rest ] -> do_chunk ( rest , f , f ( first ) , [ first ] , [ ] )
1795
1795
}
1796
1796
}
1797
1797
@@ -1808,11 +1808,11 @@ fn do_sized_chunk(
1808
1808
[ ] -> reverse ( acc )
1809
1809
remaining -> reverse ( [ reverse ( remaining ) , .. acc ] )
1810
1810
}
1811
- [ head , .. tail ] -> {
1812
- let chunk = [ head , .. current_chunk ]
1811
+ [ first , .. rest ] -> {
1812
+ let chunk = [ first , .. current_chunk ]
1813
1813
case left > 1 {
1814
- False -> do_sized_chunk ( tail , count , count , [ ] , [ reverse ( chunk ) , .. acc ] )
1815
- True -> do_sized_chunk ( tail , count , left - 1 , chunk , acc )
1814
+ False -> do_sized_chunk ( rest , count , count , [ ] , [ reverse ( chunk ) , .. acc ] )
1815
+ True -> do_sized_chunk ( rest , count , left - 1 , chunk , acc )
1816
1816
}
1817
1817
}
1818
1818
}
@@ -1864,7 +1864,7 @@ pub fn sized_chunk(in list: List(a), into count: Int) -> List(List(a)) {
1864
1864
pub fn reduce ( over list : List ( a) , with fun : fn ( a, a) -> a) -> Result ( a, Nil ) {
1865
1865
case list {
1866
1866
[ ] -> Error ( Nil )
1867
- [ head , .. tail ] -> Ok ( fold ( tail , head , fun ) )
1867
+ [ first , .. rest ] -> Ok ( fold ( rest , first , fun ) )
1868
1868
}
1869
1869
}
1870
1870
0 commit comments