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 "../src/parse_args.nim" | |
import sequtils, strutils, os | |
import tables | |
var res: Table[string, string] | |
res = parseArguments(commandLineParams) | |
echo res |
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 strutils | |
import sequtils | |
import os | |
import tables | |
proc parseArguments*(inputString: seq[string]): Table[string, string] = | |
var arguments = newSeq[string]() | |
if inputString.len == 0: | |
discard | |
else: |
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 strutils | |
import math | |
#[ | |
Module name: Implementation of MergeSort recursion. | |
Author: Benny E. | |
Mail: elgazarbenny at gmail.com | |
]# | |
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 decimal import Decimal | |
def apply_high_order(ind, element, expression_elements): | |
if element in ("*", "/"): | |
if element == "*": | |
evaluated_num = str(float(expression_elements[ind - 1]) * float(expression_elements[ind + 1])) | |
else: | |
evaluated_num = str(float(expression_elements[ind - 1]) / float(expression_elements[ind + 1])) | |
expression_elements = expression_elements[:ind - 1] + [evaluated_num] + expression_elements[ind + 2:] | |
elif element == "(": | |
if expression_elements[ind + 2] == "+": |
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
type | |
User = ref object | |
name: string | |
paymentStrategy: proc () | |
proc strategyA() = | |
echo("strategyA") | |
proc strategyB() = | |
echo("strategyB") |
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 random | |
import times | |
import sequtils | |
import strutils | |
import strformat | |
type | |
Singleton = object | |
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
import singleton | |
import times | |
import strformat | |
for _ in countup(1, 3): | |
var start = now() | |
echo("Starting test..") | |
echo(singletonInstance.value) | |
echo(fmt"took: {(now() - start).milliseconds}") |
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
proc merge[T](a: var seq[T], b: var seq[T]): seq[T] = | |
result = newSeqOfCap[T](a.len + b.len) | |
while a.len != 0 and b.len != 0: | |
if a[0] < b[0]: | |
result.add(a[0]) | |
a = a[1..^1] | |
else: | |
result.add(b[0]) | |
b = b[1..^1] |
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
-- query with stored plan | |
CREATE or replace FUNCTION pybench1(id int) RETURNS text AS ' | |
if (SD.has_key("plan")): | |
plan = SD["plan"] | |
else: | |
plan = plpy.prepare("SELECT * FROM pagetimer pt, pagebrowser pb WHERE pt.idtimer = $1 and pt.idtimer = pb.idtimer", ["int4"]) | |
SD["plan"] = plan | |
rec = plpy.execute(plan, [id]) | |
if (rec.nrows() > 0): |
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 get_lucky_version(real_floor: int): | |
floors: List[int] = [] | |
n = 1 | |
def its_a_bad_luck_floor(floor_no: int): | |
return "4" in str(floor_no) or "13" in str(floor_no) | |
for i in range(1, real_floor + 1): | |
if its_a_bad_luck_floor(n): |
OlderNewer