Sha256: 6940177f435b820efff6f123047790332c2e8838cd429e8d704c7e4ce06c229c
Contents?: true
Size: 648 Bytes
Versions: 84
Compression:
Stored size: 648 Bytes
Contents
-module(grade_school). -export([add/3, get/2, sort/1, new/0]). %% Define the grade school type -type school() :: [{integer(),[string(),...]}]. -spec add(string(), integer(), school()) -> school(). add(Name, Grade, School) -> case get(Grade, School) of [] -> orddict:store(Grade, [Name], School); Class -> orddict:store(Grade, ordsets:add_element(Name, Class), School) end. -spec get(integer(), school()) -> [string()]. get(Grade, Students) -> case orddict:find(Grade, Students) of {ok, Class} -> Class; _ -> [] end. -spec sort(school()) -> school(). sort(S) -> S. -spec new() -> school(). new() -> [].
Version data entries
84 entries across 84 versions & 1 rubygems