Demo entry 6355947

R example (functions, control flow)

   

Submitted by anonymous on Apr 15, 2017 at 01:17
Language: RConsole. Code size: 684 Bytes.

dict_dir <- tempdir()
dict_url <- 'http://downloads.sourceforge.net/wordlist/scowl-2016.01.19.zip'
dict_local_zip <- file.path(dict_dir, basename(dict_url))
if (! file.exists(dict_local_zip)) {
    download.file(dict_url, dict_local_zip)
    unzip(dict_local_zip, exdir=dict_dir)
}

dict_files <- list.files(file.path(dict_dir, 'final'), full.names=TRUE)
dict_files_match <- as.numeric(tools::file_ext(dict_files)) <= 60 & grepl("english-", dict_files, fixed = TRUE)
dict_files <- dict_files[ dict_files_match ]

words <- unlist(sapply(dict_files, readLines, USE.NAMES=FALSE))
length(words)

c("knight", "stack", "selfie", "l8er", "googling", "echinuliform") %in% words

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).