Skip to content

Instantly share code, notes, and snippets.

@VienosNotes
Created November 19, 2012 10:53
Show Gist options
  • Select an option

  • Save VienosNotes/4110085 to your computer and use it in GitHub Desktop.

Select an option

Save VienosNotes/4110085 to your computer and use it in GitHub Desktop.
11_decl_cut
let cut l n =
List.fold_left (
fun prev next ->
if (List.fold_left (fun prev next -> prev + next) 0 prev) + next > n
then prev
else prev @ [next]
) [] l;;
cut [1;2;3;4;5;6;7;8;9] 18;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment