Skip to content

Instantly share code, notes, and snippets.

View nattybear's full-sized avatar

Joonkyu Park nattybear

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] trees = new int[n];
for (int i = 0; i < n; i++)
import java.util.*;
class ListOfInteger extends ArrayList<Integer> {}
class Graph extends HashMap<Integer,ListOfInteger> {}
public class Main {
static List discovered = new ListOfInteger();
static List explored = new ListOfInteger();
module Tree where
data Tree a = Leaf a
| Node (Tree a) (Tree a)
deriving Show
type WithCounter a = Int -> (a, Int)
numberOfLeaves :: Tree a -> Integer
numberOfLeaves (Leaf _) = 1
{-# LANGUAGE GADTs #-}
module Operational where
import Control.Monad
data Program instr a where
Then :: instr a -> (a -> Program instr b) -> Program instr b
Return :: a -> Program instr a
@nattybear
nattybear / gadt.md
Last active July 24, 2022 01:54
하스켈 GADT

이 글은 하스켈 위키북스 Haskell/GADT를 읽고 정리한 것이다.

하스켈 GADT

  • Generalized Algebraic DataTypes
  • GHC 확장
  • 데이터 타입 선언 시 값 생성자에 타입을 적을 수 있게 한다.
data Maybe a where
import java.util.*;
public class Main {
static Scanner sc;
public static void main(String[] args) {
sc = new Scanner(System.in);
while (true) {
int w = sc.nextInt();
int h = sc.nextInt();
import java.util.*;
public class Main {
static Map<Integer, List<Integer>> map;
static Map<Integer, Integer> dp;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
@nattybear
nattybear / bytestring.md
Last active July 8, 2022 01:04
하스켈 ByteString

ByteString

  • 리스트랑 비슷한데 원소 하나의 크기가 1바이트이다.[^1]
  • 지연 평가 lazy 를 다루는 방식이 리스트와 다르다.
  • 패키지 이름은 bytestring

Strict

  • 모듈 이름은 Data.ByteString
  • 지연 평가를 전혀 쓰지 않는다.
@nattybear
nattybear / Main.hs
Last active June 19, 2022 03:34
Haskell The Legend of DSLs Alejandro Serrano ZuriHac 2022
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.List
import Data.Text
import Numeric.Natural