Skip to content

Instantly share code, notes, and snippets.

@Apanatshka
Forked from jastice/nobetterway?.elm
Last active August 29, 2015 14:04
Show Gist options
  • Save Apanatshka/736548c4f1d6aeb98ba7 to your computer and use it in GitHub Desktop.
Save Apanatshka/736548c4f1d6aeb98ba7 to your computer and use it in GitHub Desktop.
type Body x = { pos:(Int,Int), wrap : x }
type Bubble = { radius: Int }
type Box = { w: Int, h: Int }
data Wrap = WBox Box | WBubble Bubble
mv: (Int,Int) -> Body a -> Body a
mv (x,y) body =
let (x0,y0)= body.pos
in { body | pos <- (x0+x, y0+y)}
myBubble = Body (0,0) <| WBubble {radius=10}
myBox = Body (10,10) <| WBox {w=5, h=5}
bodies = [myBox,myBubble]
main = asText (map (mv (1,1)) bodies)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment