Geography Reference
In-Depth Information
of this reference for users of public transport. This would require an extension of
Cid by another context identifier.
In a similar vein we add to the abstract class of
Entities
to specify operations on
these properties:
class Entities e where
addLns :: e -
>
Ls -
>
e
getLnss :: e -
>
[Ls]
getLns :: e -
>
Cid -
>
[Ls]
hasLns :: e -> Cid -> Bool
Among these operations,
addLns
should allow to add a landmarkness property
to an entity of any type (in Haskell, e is a type variable). Accordingly,
getLns
should provide access to the landmarkness for the context
Cid
, or alternatively,
getLnss
should provide access to the full list of stored landmarkness properties of
an individual database entity.
For the particular data type
Entity
the semantics of these operations can be
specified as:
instance Entities Entity where
addLns (Entity ... l) ls = Entity ... (l++[ls])
getLnss e = lnss e
getLns e c = [x | x
<
- (lnss e), (cid x==c)]
hasLns e c = if (getLns e c == [])
then False
else if (lval (head (getLns e c)) > 0)
then True
else False
The first operation copies all content from the entity and appends the new
landmarkness at the end of the existing list of landmarknesses. This operation works
even if l was prior an empty list. The second operation is only an alias for the
observer that had been introduced with the data type
Entity
. The third one goes
through all elements of the list of landmarknesses of this entity, and when it finds
an element for the context
Cid
it puts it into the output list. Note that Cid should be
a unique key in an entity's list, such that the result is either a list of one element or
an empty list. The fourth operation,
hasLns
, takes the output of
getLns
—i.e., either
an empty list or a list of one element—and tests whether there is a context-related
landmarkness. Only if
lval
>0it returns
True
, and in both alternative cases it returns
False
. Either there is no landmarkness,
lval
D
0, or the landmarkness is unknown and
getLns
returns an empty list.
Search WWH ::
Custom Search