Skip to content

Instantly share code, notes, and snippets.

@JustinSDK
Last active August 30, 2016 08:02
Show Gist options
  • Save JustinSDK/cd6eb5ce723f4b991998823b6038c4fb to your computer and use it in GitHub Desktop.
Save JustinSDK/cd6eb5ce723f4b991998823b6038c4fb to your computer and use it in GitHub Desktop.
OpenSCAD max
function maximum(lt, num = 0, index = 0) =
index == len(lt) ? num : (
lt[index] > num ? maximum(lt, lt[index], index + 1) : maximum(lt, num, index + 1)
);
echo(maximum([1,3,5,7,6,4,2]));
echo(max([1,3,5,7,6,4,2])); // OpenSCAD 內建的 max 函式
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment