Created
January 10, 2011 17:04
-
-
Save nicolasff/773056 to your computer and use it in GitHub Desktop.
Allowed elements in a set.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-export([allowed/1]). | |
% null case | |
allowed([]) -> | |
[]; | |
% single element case | |
allowed([E]) -> | |
[[E]]; | |
% allowed for H|T is H only, and all that is allowed for T, | |
% as well as that same set with H included. | |
allowed([H|T]) -> | |
L = allowed(T), | |
L ++ [[H]] ++ lists:map(fun(E) -> [H|E] end, L). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment