This file contains hidden or 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
def template = '○○と●●●は違う' | |
def list = ['○○', '●●●'] | |
def translator = list.inject([:]){ result, item -> result[item] = getList(item); result } | |
// こうなる↓ | |
//def translator = [ | |
// '○○' : ['1', '2', '3', '4', '5'], | |
// '●●●' : ['あああ', 'いいい', 'ううう', 'えええ', 'おおお'] | |
//] |
This file contains hidden or 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
import hatenahaiku4j.* | |
api = new HatenaHaikuAPILight() | |
str = """ | |
def konna = api.getHotKeywordList().first() | |
def konnaUsers = konna.api.getTimeline()*.user | |
def konnaKeyword = konnaUsers.collect{ | |
it.api.getTimeline()*.keyword | |
}.flatten().unique() |
This file contains hidden or 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
// http://ja.wikipedia.org/wiki/特別:おまかせ表示 | |
def url = 'http://ja.wikipedia.org/wiki/%E7%89%B9%E5%88%A5:%E3%81%8A%E3%81%BE%E3%81%8B%E3%81%9B%E8%A1%A8%E7%A4%BA' | |
def html = new URL(url).getText('UTF-8') | |
def word = html.replaceAll(/(?s)^.+<title>| - Wikipedia<\/title>.+$/, '') | |
println word |
This file contains hidden or 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
object HelloWorld { | |
def main(args: Array[String]): Unit = { | |
System.out.println("Hello, scala!") | |
} | |
} |
This file contains hidden or 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
scala> val list = List(1, 2, 3) | |
list: List[Int] = List(1, 2, 3) | |
scala> val List(a, b, c) = list | |
a: Int = 1 | |
b: Int = 2 | |
c: Int = 3 | |
scala> a | |
res1: Int = 1 |
This file contains hidden or 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
// 2, 5, 6, 8の式の組み合わせを生成 | |
def rslt = [] | |
combiAll('+', '-', '*').collect { opes -> | |
combi(2, 5, 6, 8).collect { nums -> | |
rslt << [nums, opes + [null]].transpose().flatten()[0..-2] | |
} | |
} | |
// 答えが10になるリストを出力 | |
rslt.collect { toExp(it) }.findAll{ it.ans == 10 }.each { |
This file contains hidden or 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
def prop = new Properties() | |
prop.setProperty 'ONE', '1' | |
prop.setProperty 'TWO', '2' | |
prop.setProperty 'THREE', '3' | |
new File('/temp.properties.xml').withOutputStream{ outStream -> | |
prop.storeToXML(outStream, 'Temporary Properties') | |
} |
This file contains hidden or 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
def prop = new Properties() | |
new File('/temp.properties.xml').withInputStream{ inStream -> | |
prop.loadFromXML(inStream) | |
} | |
prop.each { | |
println "${it.key} => ${it.value}" | |
} |
This file contains hidden or 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
/* | |
* Copyright 2002-2007 the original author or authors. | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or 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
println 'Hello, World!!' |