Skip to content
CCPEDIAby Unity Nodes
Discussions/App Development/Join two list into on list without duplicationForum ↗

Join two list into on list without duplication

App Development5 posts238 views2 likesLast activity Jun 2023
PR
Pris17OP
Jun 2023

Hi all,

How to join 2 list into one list by excluding duplicate elements in the list?

@cocreature @bernhard @Julius_William

GA
Gary_Verhaegen
Jun 2023
module 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 2023

Thanks @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 2023

Assuming your element has equality defined, the elem function does that.

← Back to Discussions