This file contains 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
@echo off | |
setlocal | |
if "%~1"=="" goto thatdir | |
set destdir="%~1" | |
goto doit | |
:thatdir | |
set destdir="%~dp0" | |
:doit | |
for /R %%i in (*.mp3) do move "%%i" %destdir% | |
endlocal |
This file contains 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
strReverse <- function(x) { | |
return(paste(rev(strsplit(x, NULL)[[1]]), collapse="")) | |
} | |
# example 1 | |
s <- strReverse("abcdefghij") | |
cat(s) # output is "jihgfedcba" | |
# example 2 |
This file contains 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
strConcat <- function(x, sep="") { | |
return(paste(x, collapse=sep)) | |
} | |
# example 1 | |
s <- strConcat(c("abc", "efg", "hij")) | |
cat(s) # output is "abcefghij" | |
# example 2 |
This file contains 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
# 数値から文字列へ | |
n <- 100 | |
s <- as.character(n) | |
# 文字列から数値へ | |
s <- "1234" | |
n <- as.integer(s) |
This file contains 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
# example 1 | |
f <- file("stdin") # 標準入力 | |
s <- readLines(f) # 全行読み込み | |
cat(s[1]) # 1行目を出力 | |
# example 2 | |
s <- readLines("stdin") # 直接指定してもOK | |
cat(s, sep="\n") # 配列 s の全ての要素を"\n"(改行文字)区切りで出力 |
This file contains 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
# Brainf*ck Code Generator (固定文字列表示のみ) | |
# Author: Leonardone @ NEETSDKASU | |
# License: MIT License | |
def test_genBF() | |
f = 'TextFile.txt' | |
ARGV << f if ARGV.empty? && ARGF.eof? && FileTest.exist?(f) | |
puts genBF(ARGF.read, 60, 10) if !ARGF.eof? | |
end |
This file contains 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
// package myapp.util; | |
import java.util.Arrays; | |
public class Permutation | |
{ | |
protected final int[] unuses, stack; | |
protected int stack_end = 0; | |
protected boolean hasnext = true; | |
This file contains 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
// package myapp.util; | |
/* | |
* wrap ... e.g. int[] -> Integer[] | |
* unwrap ... e.g. Integer[] -> int[] | |
* toInt ... e.g. double[] -> int[] | |
* toDouble ... e.g. int[] -> double[] | |
* | |
*/ |
This file contains 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
-- Data.Text.split の代替(?) | |
s = ",1,2,345,6,,7,8," | |
x = split (== ',') s -- x = ["","1","2","345","6","","7","8",""] | |
split :: (a -> Bool) -> [a] -> [[a]] | |
split f str = loop str where | |
loop [] = [[]] | |
loop t = case s of | |
[] -> [w] |
This file contains 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
-- Data.List.Split.splitOn や Data.Text.splitOn の代替(?) | |
import Data.List(isPrefixOf) | |
s = "bc k abcd Efg abc b c xyz bcbc xyz bc" | |
d = "bc" | |
x = splitOn d s -- x = [""," k a","d Efg a"," b c xyz ",""," xyz ",""] | |
splitOn :: Eq a => [a] -> [a] -> [[a]] | |
splitOn [] str = error "splitOn: empty input" -- Data.Textのはエラーだが、Rubyみたいに文字単位分割したいなら [[c] | c <- str] |