Skip to content

Instantly share code, notes, and snippets.

@m93a
Created March 6, 2024 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m93a/2094f6dafc377b7536f0d639457e7dd7 to your computer and use it in GitHub Desktop.
Save m93a/2094f6dafc377b7536f0d639457e7dd7 to your computer and use it in GitHub Desktop.
# taken from github.com/dandavison/nushell-config
export def 'set difference' [s2: list] {
# nushell doesn't have a hash table so quadratic time complexity
let s1 = ($in | sort | uniq)
let s2 = ($s2 | sort | uniq)
$s1 | where {|x| not ($x in $s2)}
}
export def 'set intersection' [s2: list] {
# nushell doesn't have a hash table so quadratic time complexity
let s1 = ($in | sort | uniq)
let s2 = ($s2 | sort | uniq)
$s1 | where {|x| ($x in $s2)}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment