Join two list into on list without duplication
App Development5 posts238 views2 likesLast activity Jun 2023
PR
Pris17OP
Jun 2023Hi all,
How to join 2 list into one list by excluding duplicate elements in the list?
GA
Gary_Verhaegen
Jun 2023module Main where
import Daml.Script
import qualified DA.List
setup : Script ()
setup = script do
let list1 = [1, 3, 5, 7, 9]
let list2 = [2, 3, 5, 7, 11]
let merged = DA.List.dedup $ list1 <> list2
debug $ merged
PR
Pris17
Jun 2023Thanks @Gary_Verhaegen
PR
Pris17
Jun 2023@Gary_Verhaegen Do you know how can we check if an element is present in the list or not?
GA
Gary_Verhaegen
Jun 2023Assuming your element has equality defined, the elem function does that.