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
""" | |
pip install outlines torch==2.4.0 transformers accelerate typing-extensions pillow pdf2image rich requests | |
may need to install tkinter: https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter | |
sudo apt-get install poppler-utils | |
""" | |
from enum import Enum | |
from io import BytesIO |
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 asyncio | |
import os | |
import random | |
import hashlib | |
from datetime import datetime | |
from typing import Dict, List, Type | |
from dotenv import load_dotenv | |
from loguru import logger | |
from pydantic import BaseModel |
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
(ns parquet-layout.core) | |
(defn destock | |
([stock] stock) | |
([stock board] | |
(let [n (dec (stock board))] | |
(if (zero? n) | |
(dissoc stock board) | |
(assoc stock board n))))) |
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 lang1-parser | |
(instaparse.core/parser | |
"prog = (spaces? expr spaces? <';'> spaces?)* | |
<expr> = assig | add-sub | |
assig = varname spaces? <'='> spaces? expr | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = factor | mult |div | |
mult = mult-div spaces? <'*'> spaces? factor |
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 lang0-parser | |
(instaparse.core/parser | |
"prog = (spaces? expr spaces? <';'> spaces?)* | |
<expr> = assig | add-sub | |
assig = varname spaces? <'='> spaces? expr | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = factor | mult |div | |
mult = mult-div spaces? <'*'> spaces? factor |
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 arith-parser | |
(instaparse.core/parser | |
"prog = spaces? add-sub spaces? | |
<add-sub> = mult-div | add | sub | |
add = add-sub spaces? <'+'> spaces? mult-div | |
sub = add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = term | mult | div | |
mult = mult-div spaces? <'*'> spaces? term | |
div = mult-div spaces? <'/'> spaces? term | |
<term> = number | <'('> add-sub <')'> |
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 addmult-parser | |
(instaparse.core/parser | |
"prog= spaces? add-sub spaces? | |
<add-sub> = mult-div | add | sub | |
add= add-sub spaces? <'+'> spaces? mult-div | |
sub= add-sub spaces? <'-'> spaces? mult-div | |
<mult-div> = number | mult | div | |
mult= mult-div spaces? <'*'> spaces? number | |
div= mult-div spaces? <'/'> spaces? number | |
number= #'-?[0-9]+' |
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 addsub-parser | |
(instaparse.core/parser | |
"prog= spaces? add-sub spaces? | |
<add-sub> = number | add | sub | |
add= add-sub spaces? <'+'> spaces? number | |
sub= add-sub spaces? <'-'> spaces? number | |
number= #'-?[0-9]+' | |
<spaces> = <#'\\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
(def const-parser | |
(instaparse.core/parser | |
"prog= spaces? number spaces? | |
number=#'-?[0-9]+' | |
<spaces> = <#'[\\s]'+>")) | |
(const-parser " -123456 ") |
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
public static void swap(int[] data, int i, int j){ | |
int tmp= data[i]; | |
data[i]= data[j]; | |
data[j]= tmp; | |
} | |
public static int partition(int[] data, int begin, int end, int pivotIdx){ | |
swap(data, pivotIdx, --end); | |
pivotIdx= end; | |
int pivot= data[pivotIdx]; |
NewerOlder