Last active
August 29, 2015 14:25
-
-
Save dela3499/0212bc84e92f0bc5430e to your computer and use it in GitHub Desktop.
Succinctly expressing random number generation in a functional language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Original code to generate random numbers | |
let (nChars, seed2) = generate (int 3 5) seed1 | |
(vIndices, seed3) = generate (list nChars (int 0 1000)) seed2 | |
(cIndices, seed4) = generate (list nChars (int 0 1000)) seed3 | |
(length, seed5) = generate (int 0 2) seed4 | |
config = {vIndices = vIndices, | |
cIndices = cIndices} | |
-- Dictionary that represents computation | |
-- Same format found in http://dask.pydata.org/en/latest/spec.html | |
{'nChars': (int,3,5), | |
'vIndices': (list,'nChars',(int,0,1000)), | |
'cIndices': (list,'nChars',(int,0,1000)), | |
'length': (int,0,2)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The key insight from dask is that you can specify the graph of dependencies very simply with a dictionary of tuples.