Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -module(channels_recorder).
- -export([demo/0, surf/1]).
- -record(channel, {station, show_title, genre, repeat}).
- -define(CHANNELS, [
- #channel{station = "NBC",
- show_title = "Saturday Night Live",
- genre = "comedy",
- repeat = true},
- #channel{station = "FOX",
- show_title = "Cops",
- genre = "crime",
- repeat = true},
- #channel{station = "ESPN",
- show_title = "College Football",
- genre = "football",
- repeat = false},
- #channel{station = "HBO",
- show_title = "Curb Your Enthusiasm",
- genre = "Comedy",
- repeat = false}
- ]).
- demo() ->
- surf(?CHANNELS).
- surf(Channels) ->
- lists:foreach(fun process/1, Channels).
- process(#channel{genre = "football"} = Channel) ->
- record(Channel);
- process(#channel{genre = "comedy", repeat = false} = Channel) ->
- record(Channel);
- process(#channel{genre = "crime", show_title = "Cops"}) ->
- skip;
- process(#channel{genre = "crime"} = Channel) ->
- record(Channel);
- process(_) ->
- skip.
- record(Channel) ->
- io:format("recording ~p.~n", [Channel#channel.show_title]).
Add Comment
Please, Sign In to add comment