Skip to content

Commit

Permalink
Remove fold_right in favour of fold
Browse files Browse the repository at this point in the history
  • Loading branch information
ghivert committed Sep 17, 2024
1 parent b2af865 commit c5a5a8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/frontend/src/frontend/view/body/body.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ fn popularity_chart(model: Model) {
use <- bool.guard(when: list.is_empty(data), return: el.none())
chart.bar_chart("#ff851b", {
let acc = Dataset([], [])
use Dataset(dates, value), package <- list.fold_right(data, acc)
use Dataset(dates, value), package <- list.fold(list.reverse(data), acc)
case package.popularity {
option.None -> Dataset(dates, value)
option.Some(popularity) -> {
Expand All @@ -277,7 +277,7 @@ fn ranked_chart(model: Model) {
use <- bool.guard(when: list.is_empty(data), return: el.none())
chart.bar_chart("#ffaff3", {
let acc = Dataset([], [])
use Dataset(dates, value), package <- list.fold_right(data, acc)
use Dataset(dates, value), package <- list.fold(list.reverse(data), acc)
let label = package.name
Dataset([label, ..dates], [package.rank, ..value])
})
Expand Down
2 changes: 1 addition & 1 deletion packages/lustre/src/lustre/element.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn fragment(elements: List(Element(msg))) -> Element(msg) {
}

fn flatten_fragment_elements(elements: List(Element(msg))) {
list.fold_right(elements, [], fn(new_elements, element) {
list.fold(list.reverse(elements), [], fn(new_elements, element) {
case element {
// Only flatten one level, the runtime handles next level children
// alternatively, this could flatten deeply, but it doesn't save
Expand Down

0 comments on commit c5a5a8b

Please sign in to comment.