Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active February 15, 2017 14:54
Show Gist options
  • Save deque-blog/80846e9a72a8791c702ff288dc8ad4a4 to your computer and use it in GitHub Desktop.
Save deque-blog/80846e9a72a8791c702ff288dc8ad4a4 to your computer and use it in GitHub Desktop.
opsGen :: Gen Expr -> Int -> Gen Expr
opsGen simpleTermGen = go where
go n = do
m <- choose (0, n)
if m == 0
then simpleTermGen
else elements [add, mul] <*> replicateM m (go (div n (m + 1)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment