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
""" 中置記法の数式を後置記法に翻訳する | |
ドラゴンブックの p81 のコードを Python で書いた | |
再帰あり ver | |
""" | |
import string | |
from typing import Optional | |
from sys import argv | |
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
""" | |
0 を偶数個含む文字列の言語を受理する DFA | |
""" | |
from enum import Enum, auto | |
class DFA: | |
def __init__(self, states, alphabets, transition_pair, start_state, accept_states): | |
self.states = states | |
self.alphabets = alphabets |
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
""" | |
同値な状態を取得する 穴埋めアルゴリズム を使ってみる | |
""" | |
from enum import Enum, auto | |
from graphviz import generate_dot, tweak_q | |
from nfa import NFA | |
from states_equivalent import equivalent_pair_set |
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
def tweak_q(q): | |
if "States" in str(q): | |
return str(q).replace("States", "").replace(".", "_") | |
else: | |
return f"q{q}" | |
def generate_dot(nfa, name="sample"): | |
""" Graphviz でそのまま出力できるテキスト""" | |
result = "" |
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
""" | |
0 が 2の倍数か3の倍数の個数なら受理する NFA | |
""" | |
from enum import Enum, auto | |
from functools import reduce | |
class NFA: | |
def __init__(self, states, alphabets, transition, start_state, accept_state, E): | |
# self.states = states |
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
""" | |
0 を偶数個含む文字列の言語を受理する DFA | |
""" | |
from enum import Enum, auto | |
class DFA: | |
def __init__(self, states, alphabets, transition_method, start_state, accept_state): | |
# self.states = states | |
# self.alphabets = alphabets |
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
scriptencoding utf-8 | |
function! s:cb(timer) abort | |
if v:hlsearch | |
" マッチする文字があれば、カーソルをつける | |
if search(@/, 'cnw') !=# 0 | |
if !&cursorline | |
set cursorline | |
return | |
endif |
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
let g:Lf_Extensions = get(g:, 'Lf_Extensions', {}) | |
function! LfExt_ghq_accept(line, args) abort | |
let l:path = $GHQ_ROOT . '/github.com/' . a:line | |
execute 'tabe | tcd ' . l:path | |
endfunction | |
function! LfExt_ghq_format_line(line, args) abort | |
return a:line[11:] | |
endfunction |
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
scriptencoding utf-8 | |
" input() のときに getcmdline() で取得できる技 | |
function! NewTmpFile() abort | |
let l:winid = popup_create('', { | |
\ 'padding': [1, 1, 1, 1], | |
\ 'minwidth': 20, | |
\ 'line': 'cursor-1', | |
\ 'col': 'cursor+3', |
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
from pytwitcasting import auth, api | |
import time | |
import pyperclip | |
client_id = "取得した値" | |
client_secret = "取得した値" | |
app_basis = auth.TwitcastingApplicationBasis( | |
client_id=client_id, client_secret=client_secret | |
) |