Skip to content

Instantly share code, notes, and snippets.

@mmar
Created November 10, 2017 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmar/63c7991738b06678e1bf9537e508967a to your computer and use it in GitHub Desktop.
Save mmar/63c7991738b06678e1bf9537e508967a to your computer and use it in GitHub Desktop.
Triangular numbers.
let triangularNumbers = sequence(state: (0,0)) { (state: inout (Int,Int)) -> Int in
state = (state.0 + 1, state.1 + state.0 + 1 )
return state.1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment