Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
19
Task/String-comparison/R/string-comparison-1.r
Normal file
19
Task/String-comparison/R/string-comparison-1.r
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
compare <- function(a, b)
|
||||
{
|
||||
cat(paste(a, "is of type", class(a), "and", b, "is of type", class(b), "\n"))
|
||||
|
||||
if (a < b) cat(paste(a, "is strictly less than", b, "\n"))
|
||||
if (a <= b) cat(paste(a, "is less than or equal to", b, "\n"))
|
||||
if (a > b) cat(paste(a, "is strictly greater than", b, "\n"))
|
||||
if (a >= b) cat(paste(a, "is greater than or equal to", b, "\n"))
|
||||
if (a == b) cat(paste(a, "is equal to", b, "\n"))
|
||||
if (a != b) cat(paste(a, "is not equal to", b, "\n"))
|
||||
|
||||
invisible()
|
||||
}
|
||||
|
||||
compare('YUP', 'YUP')
|
||||
compare('BALL', 'BELL')
|
||||
compare('24', '123')
|
||||
compare(24, 123)
|
||||
compare(5.0, 5)
|
||||
20
Task/String-comparison/R/string-comparison-2.r
Normal file
20
Task/String-comparison/R/string-comparison-2.r
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
compare <- function(a, b)
|
||||
{
|
||||
cat(paste(a, "is of type", class(a), "and", b, "is of type", class(b), "\n"))
|
||||
|
||||
printer <- function(a, b, msg) cat(paste(a, msg, b, "\n"))
|
||||
|
||||
op <- c(`<`, `<=`, `>`, `>=`, `==`, `!=`)
|
||||
msgs <- c(
|
||||
"is strictly less than",
|
||||
"is less than or equal to",
|
||||
"is strictly greater than",
|
||||
"is greater than or equal to",
|
||||
"is equal to",
|
||||
"is not equal to"
|
||||
)
|
||||
|
||||
sapply(1:length(msgs), function(i) if(op[[i]](a, b)) printer(a, b, msgs[i]))
|
||||
|
||||
invisible()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue