Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions archive/r/r/remove-all-whitespace.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Remove all white spaces
args <- commandArgs(trailingOnly = TRUE)

if (length(args) == 0 || args[1] == "" || is.null(args[1]) ){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for is.null is redundant, since length(args) == 0 checks that case already.

cat("Usage: please provide a string")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should have a newline attached to it since cat doesn't add a line feed by default, and also quit(status = 1) after that to make sure it exits the program.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I withdraw this request Sir.

I am not able to do this with R Code.

}

cleaned_sentence <- gsub("\\s+", "", args[1])

cat (cleaned_sentence)
Loading