Skip to content

Instantly share code, notes, and snippets.

@chadochan
Created January 29, 2019 11:04
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 chadochan/8707d99317c1a43f031c24f5eac1d2da to your computer and use it in GitHub Desktop.
Save chadochan/8707d99317c1a43f031c24f5eac1d2da to your computer and use it in GitHub Desktop.
Rationalize converts a list of decimal representations to their closest possible rational expressions, returning a new 2D list.
// Rationalize converts a list of decimal representations to their closest possible rational expressions,
// returning a new 2D list
Rationalize {
*new { |decimal_list|
var rational_list = List();
decimal_list.do { |item, i|
rational_list.add(item.asFraction);
};
^rational_list
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment