Skip to content

Instantly share code, notes, and snippets.

@entrypointkr
Last active March 8, 2017 03:57
Show Gist options
  • Save entrypointkr/066b6e9e52bc18938d60f19e829499cc to your computer and use it in GitHub Desktop.
Save entrypointkr/066b6e9e52bc18938d60f19e829499cc to your computer and use it in GitHub Desktop.
CommandHelper subset_of() Procedure
proc _subset_of(@a, @b) {
if (!is_array(@a) || !is_array(@b)) {
return(false);
}
foreach (@key : @valueA in @a) {
@valueB = array_get(@b, @key, null);
if (@valueB == null) {
return(false);
}
if (typeof(@valueB) != typeof(@valueA)) {
return(false);
}
if (is_array(@valueB)) {
if (!_subset_of(@valueA, @valueB)) {
return(false);
}
} else {
if (!equals(@valueA, @valueB)) {
return(false);
}
}
}
return(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment