Skip to content

Instantly share code, notes, and snippets.

@timsgardner
Created November 27, 2015 21:27
Show Gist options
  • Save timsgardner/ee02efbfb5265931274a to your computer and use it in GitHub Desktop.
Save timsgardner/ee02efbfb5265931274a to your computer and use it in GitHub Desktop.
;; works
(-> [[1 0] [1 0]]
(System.Linq.Enumerable/SelectMany identity)
vec)
;; doesn't
(-> [[1 0] [1 0]]
(System.Linq.Enumerable/SelectMany identity)
(System.Linq.Enumerable/Distinct (type-args System.Linq.Enumerable))
vec)
@nasser
Copy link

nasser commented Nov 27, 2015

(macroexpand
  '(-> [[1 0] [1 0]]
    (System.Linq.Enumerable/SelectMany identity)
    (System.Linq.Enumerable/Distinct (type-args System.Linq.Enumerable))
    vec))

;; gives
(vec
 (System.Linq.Enumerable/Distinct
  (System.Linq.Enumerable/SelectMany [[1 0] [1 0]] identity)
  (type-args System.Linq.Enumerable)))

@timsgardner
Copy link
Author

ah right forgot order of type-args
still doesn't work, different error tho

(-> [[1 0] [1 0]]
  (System.Linq.Enumerable/SelectMany identity)
  (#(System.Linq.Enumerable/Distinct (type-args System.Collections.IEnumerable) %))
  vec)

@nasser
Copy link

nasser commented Nov 27, 2015

Ah, the type-arg for Distinct is the type of element in the collection, Object in this case. This does it

(->> (System.Linq.Enumerable/SelectMany [[1 0] [1 0]] identity) 
     (System.Linq.Enumerable/Distinct (type-args System.Object))
     vec)
;; [1 0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment