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 java.io._ | |
import java.net._ | |
import sun.net.www.protocol.http.HttpURLConnection | |
val url = new URL("http://api.tabelog.com/Ver2.1/RestaurantSearch/?key=value") | |
val http = url.openConnection.asInstanceOf[HttpURLConnection] | |
http.setRequestMethod("GET") |
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
<lift:surround with="default" at="content"> | |
<lift:Foo.foo> | |
<foo:button /> | |
<div id="set-here" /> | |
</lift:Foo.foo> | |
</lift:surround> |
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
class Foo { | |
def foo(xhtml:NodeSeq):NodeSeq = { | |
bind("foo", xhtml, | |
"button" -> ajaxButton("PressMe!", //ボタンに表示される文字列 | |
()=>SetHtml("set-here", Text("FooBarBaz!")) //クリック時の処理。ここではidがset-hereのdiv要素に"FooBarBaz!"をセットする | |
) | |
) | |
} | |
} |
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
class AjaxTextTest { | |
def greeting(xhtml:NodeSeq):NodeSeq = { | |
bind("greeting", xhtml, | |
"text" -> ajaxText("YourName", (s:String)=> SetHtml("here", Text("Hello, " + s + "!"))) | |
) | |
} | |
def greeting2(xhtml:NodeSeq):NodeSeq = { | |
bind("greeting", xhtml, | |
"text" -> ajaxText("YourName", true, (s:String)=> SetHtml("here2", Text("Hello, " + s + "!"))) |
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
class CssSelectorTest { | |
val alert = Run("alert('まじかよ!')") | |
val unitToAlert = () => alert | |
val strToAlert = (s:String) => alert | |
def selector = { | |
".text" #> <p>文字列でも?</p> & | |
"#button" #> ajaxButton("ボタンも置けるの?", unitToAlert) & | |
"@input" #> ajaxText("これも??", (s:String) => alert) & | |
".text2 *+" #> "置き換わっちゃうのもこうすれば!!" & | |
"button" #> "元ボタンです" & |
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
data Int = GHC.Types.I# GHC.Prim.Int# -- Defined in GHC.Types | |
instance Bounded Int -- Defined in GHC.Enum | |
instance Enum Int -- Defined in GHC.Enum | |
instance Eq Int -- Defined in GHC.Base | |
instance Integral Int -- Defined in GHC.Real | |
instance Num Int -- Defined in GHC.Num | |
instance Ord Int -- Defined in GHC.Base | |
instance Read Int -- Defined in GHC.Read | |
instance Real Int -- Defined in GHC.Real | |
instance Show Int -- Defined in GHC.Show |
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
--1 | |
halve :: [a] -> ([a], [a]) | |
halve xs = (take len xs, drop len xs) | |
where | |
len = fromIntegral (length xs) `div` 2 | |
--2 | |
-- if | |
safetail :: (Eq a) => [a] -> [a] | |
safetail xs = if xs == [] then [] else drop 1 xs |
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
-- 1 | |
-- square = sum [x^2 | x <- [1 .. 100] | |
--2 | |
replicate :: Int -> a -> [a] | |
replicate n x = [x | _ <- [1 .. n]] | |
--3 | |
pyths :: Int -> [(Int,Int,Int)] | |
pyths n = [(x,y,z) | x <- [1..n], y<-[1..n], z<-[1..n], x^2+y^2==z^2] |
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
--1 | |
power :: Int -> Int -> Int | |
power m n | n < 0 = 0 | |
| n == 0 = 1 | |
| otherwise = m * power m (n-1) | |
{- | |
power 2 3 | |
2 * ( power 2 2 ) | |
2 * 2 * ( power 2 1) | |
2 * 2 * 2 * ( power 2 0) |
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
-- 8, 9がわかりましぇん(´;ω;`)ブワッ | |
import Data.Char | |
--1 | |
--[f x|x <- xs, p x] | |
-- | |
--(map f).(filter p) | |
--2 |
OlderNewer