algorithm - How to diff/substract two lists in Clojure -


उदाहरण:

  1 1 3 3 4 4 5 5 6 एल 1 1 3 3 4 5 L2 1 1 4 5 6 Res   

प्रतिबंध:

  1. अंतर / घटाव को एल 1 शून्य से तत्वों के "सेट" के रूप में परिभाषित किया गया है
  2. एल 2 हमेशा एल 1 और एल 2 के तत्वों में डुप्लिकेट हो सकते हैं
  3. तत्व प्राथमिकताएं हैं (इंट, स्ट्रिंग) और एक ही प्रकार

    (clojure.set / difference) यहां (3) की मदद नहीं करता है ।

      (defn diff [s1 s2] (मैपैक (fn [[xn]] ( उदाहरण के लिए, दिए गए  
      (डीईएफटी एल 1 [डीएपी एलए 1] 1 1 1 3 3 4 4 5 5 6]) (def L2 [1 3 3 4 5])   

    तब

      (diff L1 L2) ; (1 1 4 5 6)    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -