Skip to content

Instantly share code, notes, and snippets.

@brianclements
Created March 14, 2016 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brianclements/1deddb0915bd012d4c0a to your computer and use it in GitHub Desktop.
Save brianclements/1deddb0915bd012d4c0a to your computer and use it in GitHub Desktop.
Infinite currying using tail-recursion in Racket
#lang racket
(define (rec-curry-add [inc 0] [sum 0])
(if (equal? inc 0)
sum
(begin
(set! sum (+ sum inc))
(lambda ([inc 0])
(rec-curry-add inc sum)))))
(rec-curry-add)
((rec-curry-add 1))
(((rec-curry-add 1)2))
@brianclements
Copy link
Author

0
1
3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment