-
Notifications
You must be signed in to change notification settings - Fork 1
Create test.rkt #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
7fef5ec to
bb2a00d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 1 file in this pull request and has added suggestions.
1aef0fd to
a3341f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 1 file in this pull request and has added suggestions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resyntax analyzed 1 file in this pull request and has added suggestions.
| (define (distance x1 y1 x2 y2) | ||
| (let ([dx (- x1 x2)] | ||
| [dy (- y1 y2)]) | ||
| (sqrt (+ (* dx dx) (* dy dy))))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let-to-define Internal definitions are recommended instead of let expressions, to reduce nesting.
| (define (distance x1 y1 x2 y2) | |
| (let ([dx (- x1 x2)] | |
| [dy (- y1 y2)]) | |
| (sqrt (+ (* dx dx) (* dy dy))))) | |
| (define (distance x1 y1 x2 y2) | |
| (define dx (- x1 x2)) | |
| (define dy (- y1 y2)) | |
| (sqrt (+ (* dx dx) (* dy dy)))) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines
'#("(define (distance x1 y1 x2 y2)"
" (define dx (- x1 x2))"
" (define dy (- y1 y2))"
" (sqrt (+ (* dx dx) (* dy dy))))")
#:original-lines
'#("(define (distance x1 y1 x2 y2)"
" (let ([dx (- x1 x2)]"
" [dy (- y1 y2)])"
" (sqrt (+ (* dx dx) (* dy dy)))))")
#:start-line 4)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/let-binding-suggestions.rkt:44:3 (define (distance x1 y1 x2 y2) NEWLINE (define dx (- x1 x2)) NEWLINE (define dy (- y1 y2)) NEWLINE (sqrt (+ (* dx dx) (* dy dy))))>
#:original-syntax
#<syntax:test.rkt:4:0 (define (distance x1 y1 x2 y2) (let ((dx (- x1 x2)) (dy (- y1 y2))) (sqrt (+ (* dx dx) (* dy dy)))))>)| (sqrt (+ (* dx dx) (* dy dy))))) | ||
|
|
||
|
|
||
| (or 1 (or 2 3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nested-or-to-flat-or Nested or expressions can be flattened to a single, equivalent or expression.
| (or 1 (or 2 3)) | |
| (or 1 2 3) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines '#("(or 1 2 3)")
#:original-lines '#("(or 1 (or 2 3))")
#:start-line 10)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/boolean-shortcuts.rkt:34:3 (or 1 2 3)>
#:original-syntax #<syntax:test.rkt:10:0 (or 1 (or 2 3))>)| (or 1 (or 2 3)) | ||
|
|
||
|
|
||
| (if 'cond 'then (if 'cond2 'then2 'else)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nested-if-to-cond This if-else chain can be converted to a cond expression.
| (if 'cond 'then (if 'cond2 'then2 'else)) | |
| (cond | |
| ['cond 'then] | |
| ['cond2 'then2] | |
| [else 'else]) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines
'#("(cond" " ['cond 'then]" " ['cond2 'then2]" " [else 'else])")
#:original-lines '#("(if 'cond 'then (if 'cond2 'then2 'else))")
#:start-line 13)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/conditional-shortcuts.rkt:45:3 (cond NEWLINE ((quote cond) (quote then)) NEWLINE ((quote cond2) (quote then2)) NEWLINE (else (quote else)))>
#:original-syntax
#<syntax:test.rkt:13:0 (if (quote cond) (quote then) (if (quote cond2) (quote then2) (quote else)))>)| (if 'a | ||
| (println "true branch") | ||
| #f) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if-else-false-to-and This if expression can be refactored to an equivalent expression using and.
| (if 'a | |
| (println "true branch") | |
| #f) | |
| (and 'a | |
| (println "true branch")) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines '#("(and 'a" " (println \"true branch\"))")
#:original-lines '#("(if 'a" " (println \"true branch\")" " #f)")
#:start-line 16)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/boolean-shortcuts.rkt:84:3 (and (ORIGINAL-SPLICE (quote a) (println "true branch")))>
#:original-syntax
#<syntax:test.rkt:16:0 (if (quote a) (println "true branch") #f)>)| (for-each | ||
| (λ (x) | ||
| (displayln x) | ||
| (displayln x)) | ||
| some-list) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for-each-to-for This for-each operation can be replaced with a for loop.
| (for-each | |
| (λ (x) | |
| (displayln x) | |
| (displayln x)) | |
| some-list) | |
| (for ([x (in-list some-list)]) | |
| (displayln x) | |
| (displayln x)) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines
'#("(for ([x (in-list some-list)])" " (displayln x)" " (displayln x))")
#:original-lines
'#("(for-each"
" (λ (x)"
" (displayln x)"
" (displayln x))"
" some-list)")
#:start-line 22)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/for-loop-shortcuts.rkt:149:3 (for ((x (in-list some-list))) NEWLINE (ORIGINAL-SPLICE (displayln x) (displayln x)))>
#:original-syntax
#<syntax:test.rkt:22:0 (for-each (λ (x) (displayln x) (displayln x)) some-list)>)| (ormap | ||
| (λ (x) | ||
| (and (number? x) | ||
| (positive? x) | ||
| (even? x) | ||
| (< x 10))) | ||
| some-list2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ormap-to-for/or This ormap operation can be replaced with a for/or loop.
| (ormap | |
| (λ (x) | |
| (and (number? x) | |
| (positive? x) | |
| (even? x) | |
| (< x 10))) | |
| some-list2) | |
| (for/or ([x (in-list some-list2)]) | |
| (and (number? x) | |
| (positive? x) | |
| (even? x) | |
| (< x 10))) |
Debugging details below:
Textual replacement
(line-replacement
#:new-lines
'#("(for/or ([x (in-list some-list2)])"
" (and (number? x)"
" (positive? x)"
" (even? x)"
" (< x 10)))")
#:original-lines
'#("(ormap"
" (λ (x)"
" (and (number? x)"
" (positive? x)"
" (even? x)"
" (< x 10)))"
" some-list2)")
#:start-line 30)Syntactic replacement
(syntax-replacement
#:new-syntax
#<syntax:/home/runner/.local/share/racket/8.5/pkgs/resyntax/default-recommendations/for-loop-shortcuts.rkt:158:3 (for/or ((x (in-list some-list2))) NEWLINE (and (number? x) (positive? x) (even? x) (< x 10)))>
#:original-syntax
#<syntax:test.rkt:30:0 (ormap (λ (x) (and (number? x) (positive? x) (even? x) (< x 10))) some-list2)>)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sorawee fixed 😄
@samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges. The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
Analyze pull requests with Resyntax @samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges. The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
Analyze pull requests with Resyntax @samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges. The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
Analyze pull requests with Resyntax @samth expressed interest in setting up [Resyntax](https://docs.racket-lang.org/resyntax/) in the Typed Racket repository. This CL adds a github workflow which runs Resyntax on any changed files in a pull request. Resyntax will suggest changes in the form of a github review, [like this](jackfirth/racket-package-resyntax-action#9 (review)). To apply the changes, the pull request author simply need click the "Commit suggestion" button that shows up in each comment. Suggestions can also be ignored freely; the review does not block merges. The tool and the github integration are both still in the early phases so there are probably several bugs to work out here. If a suggestion looks wonky, @-mention me and I'll take a look at it.
No description provided.