Sha256: 933a46dfe895d371518f0d52570b5368771224521f8a7ab307880c426df71582

Contents?: true

Size: 743 Bytes

Versions: 66

Compression:

Stored size: 743 Bytes

Contents

module GradeSchool exposing (addStudent, allStudents, empty, studentsInGrade)

import Dict exposing (..)


type alias Grade =
    Int


type alias Student =
    String


type alias School =
    Dict Int (List Student)


empty : School
empty =
    Dict.empty


addStudent : Grade -> Student -> School -> School
addStudent grade student school =
    Dict.insert grade (List.sort (student :: studentsInGrade grade school)) school


studentsInGrade : Grade -> School -> List Student
studentsInGrade grade school =
    case Dict.get grade school of
        Just list ->
            list

        Nothing ->
            []


allStudents : School -> List ( Grade, List Student )
allStudents school =
    Dict.toList school |> List.sortBy Tuple.first

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.179 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.178 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.177 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.176 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.175 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.174 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.173 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.172 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.171 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.170 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.169 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.167 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.166 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.165 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.164 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.163 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.162 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.161 tracks/elm/exercises/grade-school/GradeSchool.example.elm
trackler-2.2.1.160 tracks/elm/exercises/grade-school/GradeSchool.example.elm