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 Data.Array | |
import Data.Array.ST | |
import Control.Monad (forM_, liftM2) | |
main = print $ exchanges coins 10000 ! 10000 | |
where | |
coins = [1, 5, 10, 50, 100, 500, 1000, 2000, 5000, 10000] | |
exchanges :: (Ix a, Enum a, Num a, Num e) => [a] -> a -> Array a e | |
exchanges cs n = runSTArray $ do |
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
mappings.addUserMap( | |
[modes.COMMAND_LINE], | |
['<C-x>'], | |
'toggle bang', | |
function() { | |
let [,cmd,bang,args] = commands.parseCommand(commandline.command); | |
bang = bang ? '' : '!'; | |
commandline.command = cmd + bang + ' ' + args; | |
}); |
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
# require ghc-paths <http://hackage.haskell.org/package/ghc-paths> | |
% echo 'length x' | ./hint | |
[a] | |
% echo 'x + 1' | ./hint | |
(GHC.Num.Num a) => a | |
% echo 'foldl x 0 [2,3]' | ./hint | |
(GHC.Num.Num a, GHC.Num.Num b) => a -> b -> a | |
% echo 'nub x' | ./hint Data.List | |
(GHC.Classes.Eq a) => [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
command! -nargs=0 CompileThis call s:compile_this() | |
let s:compile_cmd = { | |
\ 'c': 'gcc -c -Wall', | |
\ 'cpp': 'g++ -c -Wall -std=c++0x', | |
\ 'haskell': 'ghc -c -Wall' | |
\ } | |
function! s:compile_this() | |
if !has_key(s:compile_cmd, &l:filetype) | |
echoerr "I don't know how to compile" | |
return |
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
" Move window position {{{ | |
nnoremap <silent> <Plug>swap_window_next :<C-u>call <SID>swap_window(v:count1)<CR> | |
nnoremap <silent> <Plug>swap_window_prev :<C-u>call <SID>swap_window(-v:count1)<CR> | |
nnoremap <silent> <Plug>swap_window_j :<C-u>call <SID>swap_window_dir(v:count1, 'j')<CR> | |
nnoremap <silent> <Plug>swap_window_k :<C-u>call <SID>swap_window_dir(v:count1, 'k')<CR> | |
nnoremap <silent> <Plug>swap_window_h :<C-u>call <SID>swap_window_dir(v:count1, 'h')<CR> | |
nnoremap <silent> <Plug>swap_window_l :<C-u>call <SID>swap_window_dir(v:count1, 'l')<CR> | |
nnoremap <silent> <Plug>swap_window_t :<C-u>call <SID>swap_window_dir(v:count1, 't')<CR> | |
nnoremap <silent> <Plug>swap_window_b :<C-u>call <SID>swap_window_dir(v:count1, 'b')<CR> |
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
nnoremap <silent> <Plug>select_cstyle_if :<C-u>call <SID>select_cstyle_if()<CR> | |
function! s:select_cstyle_if() " {{{ | |
let orig_view = winsaveview() | |
let if_start_pos = [] | |
while searchpair('{', '', '}', 'bW', 'synIDattr(synID(line("."), col("."), 0), "name") =~? "string\\|character"') != 0 | |
let brace_start_pos = getpos('.') | |
normal! ge | |
let save = @" | |
normal! yl | |
let 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
-- original: http://d.hatena.ne.jp/kazu-yamamoto/20100528/1275008906 | |
import Control.Applicative | |
import Control.Monad | |
import Data.Array.ST | |
import Data.Array.Unboxed | |
import Random | |
---------------------------------------------------------------- | |
type Value = Int |
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
function! ParseJSON(str) | |
let obj = { 'str': a:str, 'pos': 0, 'len': len(a:str) } | |
function! obj.skip_space() dict | |
let self.pos = matchend(self.str, '^\s*', self.pos) | |
endfunction | |
function! obj.parse_string() dict | |
if self.str[self.pos] != '"' | |
throw 'not a string' |
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
" For test (Do quickrun on the target character!): | |
" aiu | |
" あいう | |
function! s:get_current_character() | |
if mode() ==# 'c' | |
let str = getcmdline() | |
let cur_idx = getcmdpos() - 1 | |
return matchstr(str, '.', cur_idx) |
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 ExistentialQuantification #-} | |
import System | |
class Hi_ a where | |
hi :: a -> String | |
data Hi = forall a. Hi_ a => Hi a | |
instance Hi_ Hi where | |
hi (Hi x) = hi x | |
data Ujihisa = Ujihisa |