• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Oo for fp
 

Oo for fp

on

  • 356 views

 

Statistics

Views

Total Views
356
Views on SlideShare
356
Embed Views
0

Actions

Likes
0
Downloads
1
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Oo for fp Oo for fp Presentation Transcript

    • (defrecord  CartesianCoordinate  [x  y])
    • (defrecord  PolarCoordinate  [distance  angle])
    • (defprotocol  Moveable    (move-­‐north  [self  amount])    (move-­‐east    [self  amount]))
    • (extend-­‐type  CartesianCoordinate    Moveable    (move-­‐north  [{x  :x  y  :y}  ammount]        (CartesianCoordinate.  (+  x  ammount)  y))    (move-­‐east  [{x  :x  y  :y}  ammount]        (CartesianCoordinate.  x  (+  y  ammount))))
    • (defrecord  CenterPointRectangle  [center-­‐point  width  height])
    • (defrecord  CornerPointRectangle  [top-­‐left  bottom-­‐right])
    • (extend-­‐type  CenterPointRectangle      Moveable    (move-­‐north  [self  ammount]        (update-­‐in  self  [:center-­‐point]                              #(move-­‐x  %  ammount)))    (move-­‐east  [self  ammount]        (update-­‐in  self  [:center-­‐point]                              #(move-­‐y  %  ammount))))