Repository navigation
Conversation
8 of 11 tasks
Anirban166
reviewed
May 29, 2024
tdhock
requested changes
Jun 1, 2024
Member
Author
|
From R-CMD-Check: > # fcase can be used for recursion, unlike fifelse
> gcd_dt <- function(x,y) {
+ r <- x
+ return(fcase(!r, y, r, gcd_dt(x, y))) # Recursive call must be in the last when-value pair
+ }
> gcd_dt(10, 1)
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Execution haltednot sure why mod operator isn't showing up here, will investigate Edit: Rd files have to use escaped percent symbols, otherwise it marks the beginning of an Rd comment |
tdhock
requested changes
Jun 1, 2024
tdhock
requested changes
Jun 3, 2024
| ) | ||
|
|
||
| # fcase can be used for recursion, unlike fifelse | ||
| gcd_dt = function(x,y) { |
Member
There was a problem hiding this comment.
i guess this is greatest common denominator? can you please add a comment to explain?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #4549
fifelseevaluates bothyesandnoarguments, regardless of the value oftest. This makes it unfit for recursive functions as the evaluation will cause an infinite loop of calls.Changed documentation to better reflect this behavior, along with a simple example to showcase the difference against base
ifelse:Also mentioned that
fcasecan be used instead for recursive calls. Doesfcasedocumentation also need updating? I noticed that thewhenandvaluepair is evaluated, even if thewhendoesn't bind, which means:works, but
doesn't, due to the same reason that
fifelsedoesn't.