1

I try to fetch a list of addresses with expired date by appending the address to list(address). However when doing map iteration, it encounters a persistent error says 'not True'.

Hope someone can guide a bit here. Thanks in advance!

Below is part of the code:

function checkPoint (var s : contract_storage) : contract_storage is 
 begin
   function iter_op (const m : register) : list(address) is
    block {
      const removing_list : list(address) = list [];
      function iterated (const i : address; const j : counter) : list(address) is
        if j.maturityTime <= Tezos.now then i # removing_list else removing_list;
    } with Map.iter (iterated, m);  //error says: characters 11-33. Not true
   const remove_creditors : list(address) = iter_op (s.creditorsMap);  //creditorsMap is  map (address, counter)
   //...
   // if above is bug free, I will start to remove the list of items in the map one by one 
 end with s
0

the fold operation would be a fit...

const removing_list : list(address) = list [];

function fold_op (const m : register) : list(address) is
  block {
    function folded (const i : list(address); const j : address * counter) : list(address) is
      if j.1.maturityTime <= Tezos.now then j.0 # i else i;
  } with Map.fold (folded, m, removing_list)


function checkPoint (var s : contract_storage) : contract_storage is 
 begin
   const remove_creditors : list(address) = fold_op (s.creditorsMap); // the crucial part
   s := List.fold (removeCreditor, remove_creditors, s); //other operations irrelevant to the question
 end with s
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.