Skip to content

Instantly share code, notes, and snippets.

View Javran's full-sized avatar

Javran Cheng Javran

View GitHub Profile
@Javran
Javran / memoize.js
Created July 3, 2017 03:54
memoize using nested Map assuming fixed function arity
// `deepWrite(map)([k1,k2,k3...])(value)`
// - assigns `value` to `map.get(k1).get(k2).get(k3)...`.
// - new Map objects are created if some key is missing along the path.
// - INVARIANT: keys.length >= 1
const deepWrite = map => keys => value => {
if (keys.length === 0) {
console.error(`invariant violation: empty key array`)
return undefined
}
if (keys.length === 1) {
@Javran
Javran / ASWTest.hs
Last active May 15, 2017 01:01
ASW equipments
{-# LANGUAGE
NoMonomorphismRestriction
, PartialTypeSignatures
, MultiWayIf
#-}
{-# OPTIONS_GHC -fno-warn-partial-type-signatures #-}
module ASWTest where
import Data.List
import Text.Printf
@Javran
Javran / 250x250.png
Last active March 29, 2017 19:15
tmptmp
250x250.png
@Javran
Javran / AlterTest.hs
Last active March 8, 2017 23:22
parsing a set of strings
{-# LANGUAGE ScopedTypeVariables, TupleSections #-}
module AlterTest where
import Data.Foldable
import Data.Tree
import qualified Data.Map.Strict as M
import Control.Monad
import qualified Text.ParserCombinators.ReadP as Parser
import Test.QuickCheck
import Data.List
{
"api_result":1,
"api_result_msg":"\u6210\u529f",
"api_data":{
"api_ship_id":[
-1,
721,
620,
620,
543,
{-# LANGUAGE FlexibleInstances #-}
module MMorphTest where
import Control.Monad
import Control.Monad.Morph
import Control.Monad.State
import Control.Monad.Reader
import Control.Monad.Writer
import Control.Monad.Trans.Maybe
import Data.Monoid
{-# LANGUAGE RankNTypes, ScopedTypeVariables #-}
module ParsecTest where
import Text.Parsec
import Text.Parsec.Prim
import Control.Monad.Morph
newtype ParsecT2 s u m a
= ParsecT2 {unParser2 :: forall b .
State s u
@Javran
Javran / pasw-level.md
Last active July 6, 2016 22:59
preemptive anti-sub attack level requirement

*: remodel level is sufficient

CL / CLT / CT

Name ASW >= 68 ASW >= 72
五十鈴改二 50* 50*
那珂改二 55 66
酒匂改 70 77
木曾改二 72 80

null is used if no ship is at that position.

for normal fleet battles:

 {
  "main":[
    {
      "hp":4,
      "sunk":false,
module Vehora where
import Control.Monad
import Control.Monad.Fix
logIn :: IO ()
logIn = do
putStrLn "% Enter password:"
fix $ \go -> do
guess <- getLine