Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
Vorlesung 2015
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FFPiH
Vorlesung 2015
Commits
d87db40e
Commit
d87db40e
authored
9 years ago
by
Jonas Betzendahl
Browse files
Options
Downloads
Patches
Plain Diff
Beispielcode für Sort und Typo
parent
cd7ed5db
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
exampleCode/lecture8/sort.hs
+32
-0
32 additions, 0 deletions
exampleCode/lecture8/sort.hs
lecture7.pdf
+0
-0
0 additions, 0 deletions
lecture7.pdf
with
32 additions
and
0 deletions
exampleCode/lecture8/sort.hs
0 → 100644
+
32
−
0
View file @
d87db40e
module
Main
where
import
Data.List
import
Test.QuickCheck
-- Sorting twice changes nothing
prop_idempotency
::
Ord
a
=>
[
a
]
->
Bool
prop_idempotency
xs
=
qsort
xs
==
qsort
(
qsort
xs
)
-- Sorting doesn't change the length
prop_len
::
Ord
a
=>
[
a
]
->
Bool
prop_len
xs
=
length
xs
==
length
(
qsort
xs
)
-- Sorted result is a permutation of input
prop_perm
::
Ord
a
=>
[
a
]
->
Bool
prop_perm
xs
=
(
qsort
xs
)
`
elem
`
(
permutations
xs
)
-- Sorting produces sorted list
prop_sort
::
Ord
a
=>
[
a
]
->
Bool
prop_sort
=
isSorted
.
qsort
where
isSorted
::
Ord
a
=>
[
a
]
->
Bool
isSorted
[]
=
True
isSorted
[
x
]
=
True
isSorted
(
x
:
y
:
zs
)
=
(
x
<=
y
)
&&
isSorted
(
y
:
zs
)
qsort
::
Ord
a
=>
[
a
]
->
[
a
]
qsort
[]
=
[]
qsort
(
p
:
xs
)
=
(
qsort
lesser
)
++
p
:
(
qsort
greater
)
where
lesser
=
filter
(
<
p
)
xs
greater
=
filter
(
>=
p
)
xs
This diff is collapsed.
Click to expand it.
lecture7.pdf
+
0
−
0
View file @
d87db40e
No preview for this file type
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment