NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

module Opdracht1 where
import Data.List

data Kleur = Rood | Blauw | Geel
deriving Show

data Geofig = Vierkant Double Kleur--datatype Vierkant met lengte Double
| Rechthoek Double Double Kleur--datatype Vierkant met riblengte Double en Double
| Driehoek Double Kleur--datatype Driehoek met riblengte Double
| Cirkel Double Kleur--datatype Cirkel met straal Double
deriving Show

roodVierkant = Vierkant 2.0 Rood
blauwCirkel = Cirkel 3.0 Blauw
geelRechthoek = Rechthoek 3.0 5.0 Geel
roodRechthoek = Rechthoek 3.0 6.0 Rood
blauwDriehoek = Driehoek 5.5 Blauw

figlist = [roodVierkant , blauwCirkel , geelRechthoek, roodRechthoek, blauwDriehoek, blauwCirkel]

--geoOppervlakte:: Geofig -> Float
geoOppervlakte (Vierkant riblengte _) = riblengte * riblengte
geoOppervlakte (Rechthoek riblengteA riblengteB _) = riblengteA * riblengteB
geoOppervlakte (Driehoek riblengte _) = (riblengte^2) * ((sqrt 3.0) / 4.0)
geoOppervlakte (Cirkel straal _) = pi * straal^2

geoOmtrek (Vierkant riblengte _) = riblengte * 4
geoOmtrek (Rechthoek riblengteA riblengteB _) = riblengteA * 2 + 2 * riblengteB
geoOmtrek (Driehoek riblengte _) = riblengte * 3
geoOmtrek (Cirkel straal _) = pi*2 * straal

geoIsVierkant::Geofig -> Bool
geoIsVierkant (Vierkant _ _) = True
geoIsVierkant _ = False

geoIsCirkel::Geofig -> Bool
geoIsCirkel (Cirkel _ _) = True
geoIsCirkel _ = False

geoIsRechthoek::Geofig -> Bool
geoIsRechthoek (Rechthoek _ _ _) = True
geoIsRechthoek _ = False

geoIsDriehoek::Geofig -> Bool
geoIsDriehoek (Driehoek _ _) = True
geoIsDriehoek _ = False

geefVierkanten::[Geofig] -> [Geofig]
geefVierkanten a = filter geoIsVierkant a

geoKleur::Geofig -> Kleur
geoKleur (Rechthoek _ _ a) = a
geoKleur (Driehoek _ a) = a
geoKleur (Cirkel _ a) = a
geoKleur (Vierkant _ a) = a

kleurName::Kleur -> String
kleurName Rood = "Rood"
kleurName Blauw = "Blauw"
kleurName Geel = "Geel"

isGeofigKleur::Kleur -> Geofig -> Bool
isGeofigKleur b a = kleurName (geoKleur a) == kleurName b

geefGeofig::[Geofig]->String->[Geofig]
geefGeofig a b
| b == "Vierkant" = filter geoIsVierkant a
| b == "Driehoek" = filter geoIsDriehoek a
| b == "Cirkel" = filter geoIsCirkel a
| b == "Rechthoek" = filter geoIsRechthoek a

geefGeofigMetKleur::Kleur->[Geofig]->[Geofig]
geefGeofigMetKleur b a = filter (isGeofigKleur b) a

geoGrootsteOpp::Geofig->Geofig->Geofig
geoGrootsteOpp a b
| geoOppervlakte a < geoOppervlakte b = b
| otherwise = a

geoGrootsteOmt::Geofig->Geofig->Geofig
geoGrootsteOmt a b
| geoOmtrek a < geoOmtrek b = b
| otherwise = a

rmdups :: (Ord a) => [a] -> [a]
rmdups = map head . group . sort

geefGeofigGrootsteOpp::[Geofig]->[Geofig]
geefGeofigGrootsteOpp [] = []
geefGeofigGrootsteOpp [x] = [x]
geefGeofigGrootsteOpp (x:xs)
| geoOppervlakte x < geoOppervlakte (head xs) = geefGeofigGrootsteOpp xs
| geoOppervlakte x > geoOppervlakte (head xs) = geefGeofigGrootsteOpp (xs ++ [x])
| length (rmdups (map geoOppervlakte (x:xs))) == 1 = (x:xs)
| otherwise = geefGeofigGrootsteOpp (xs ++ [x])

geefGeofigGrootsteOmtr::[Geofig]->[Geofig]
geefGeofigGrootsteOmtr [] = []
geefGeofigGrootsteOmtr [x] = [x]
geefGeofigGrootsteOmtr (x:xs)
| geoOmtrek x < geoOmtrek (head xs) = geefGeofigGrootsteOmtr xs
| geoOmtrek x > geoOmtrek (head xs) = geefGeofigGrootsteOmtr (xs ++ [x])
| length (rmdups (map geoOmtrek (x:xs))) == 1 = (x:xs)
| otherwise = geefGeofigGrootsteOmtr (xs ++ [x])


     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.