Skip to content

Instantly share code, notes, and snippets.

@lovasoa
Last active August 29, 2015 13:57
Show Gist options
  • Save lovasoa/9717946 to your computer and use it in GitHub Desktop.
Save lovasoa/9717946 to your computer and use it in GitHub Desktop.
Plot a mathematical function in the terminal. In one line of coffeescript.
#Enter this line in the REPL coffeescript console
plot = (f,a,b) -> ((if 0<=n<75*f(i) or 75*f(i)<n<0 then '█' else ' ') for n in [-75..75]).join '' for i in (i for i in [a..b] by 0.05)
#Then, you can start plotting functions
plot Math.sin, 0, 2*Math.PI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment