Skip to content

Instantly share code, notes, and snippets.

@viveksoundrapandi
Created January 16, 2020 03:53
Show Gist options
  • Save viveksoundrapandi/19c4aa3ec1dc0f5235f561ebd76db696 to your computer and use it in GitHub Desktop.
Save viveksoundrapandi/19c4aa3ec1dc0f5235f561ebd76db696 to your computer and use it in GitHub Desktop.
curry ruby native version
From: proc.c (C Method):
Owner: Proc
Visibility: public
Number of lines: 19
static VALUE
proc_curry(int argc, const VALUE *argv, VALUE self)
{
int sarity, max_arity, min_arity = rb_proc_min_max_arity(self, &max_arity);
VALUE arity;
rb_scan_args(argc, argv, "01", &arity);
if (NIL_P(arity)) {
arity = INT2FIX(min_arity);
}
else {
sarity = FIX2INT(arity);
if (rb_proc_lambda_p(self)) {
rb_check_arity(sarity, min_arity, max_arity);
}
}
return make_curry_proc(self, rb_ary_new(), arity);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment