How to iterate all transaction in a list inside a record account

ho can iterate the transaction history

     contract LipaAccount=
                  record account = {
                     name    : string,
                     balance : int,
                     history : list(transaction) 

             record transaction = {
                          id : int,
                          amount: int,
                          txt_id : string //random hash string

what i want is to get account and iterate all the transactions history

1 Like

Hello, there is multiple ways you can do, e.g. using the list standard library with include "List.aes" and then using, List.foldr(...), List.fold(...), List.foreach(...) or , List.flat_map(...).

Otherwise you can recursively iterate manually.

function loop_history(history : list(transaction)) =
    [] => ()
    one_tx :: remaining_txs =>
      do_something(one_tx )
1 Like