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
package main | |
import ( | |
"code.google.com/p/go-tour/wc" | |
"strings" | |
) | |
func WordCount(s string) map[string]int { | |
tab := make(map[string]int) | |
for _, w := range strings.Fields(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
package main | |
import "code.google.com/p/go-tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
pic := make([][]uint8, dy) | |
for y := 0; y < dy; y++ { | |
pic[y] = make([]uint8, dx) | |
} | |
for y, pr := range pic { |
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
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
func Sqrt(x float64) float64 { | |
z := 1.0; | |
for i := 0; i < 10; i++ { |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac |
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 Term = TTrue | TFalse | Zero | |
| Succ Term | Pred Term | IsZero Term | |
| If Term Term Term | |
deriving (Eq, Show) | |
eval :: Term -> Term | |
eval (IsZero Zero) = TTrue | |
eval (IsZero TTrue) = TFalse | |
eval (IsZero TFalse) = TFalse | |
eval (IsZero t) = isZero $ eval t |
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 | |
------ | |
(選択肢文字列,値)のリストをとって、ユーザーに選択肢を提示し、番号を入力して選んでもらった値を返す関数 | |
``` {haskell} | |
choice :: [(String, a)] -> IO a | |
``` |
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
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{- | |
問題:コロンをつかってみよう | |
data k :> v = k :> v deriving (Eq, Show) | |
data k :=> v = Nil | |
| (k :> v) :+ (k :=> v) |
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
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE NoMonomorphismRestriction #-} | |
class VLArg a where | |
vla :: Show b => [String] -> b -> a | |
instance VLArg (IO ()) where | |
vla acc a = putStrLn $ vla acc a |
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
module Bookmark ( | |
Bookmark (..), | |
toJson | |
) where | |
import Data.List (intercalate) | |
data Bookmark = | |
Bookmark String String | | |
Folder String [Bookmark] |
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
[Desktop Entry] | |
Version=1.0 | |
Name=Leksah | |
Comment=Haskell IDE | |
GenericName=Haskell IDE | |
Keywords=Haskell;IDE | |
Exec=leksah | |
Terminal=false | |
X-MultipleArgs=false | |
Type=Application |