This file contains 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
fn compare(s1: DTypePointer[DType.uint8], s2: DTypePointer[DType.uint8], count: Int)->Int: | |
var result = 0 | |
var i = 0 | |
while i < count: | |
var s1i = s1[i] | |
var s2i = s2[i] | |
var smaller = s1i < s2i | |
var bigger = s1i > s2i | |
i += 1 + count * int(smaller or bigger) | |
result = -1 * int(smaller) + 1 * int(bigger) |
This file contains 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
trait Hashable: | |
fn __hash__[H: Hasher](self, inout hasher: H): | |
... | |
trait Hasher: | |
fn __init__(inout self): | |
... | |
fn update(inout self, bytes: DTypePointer[DType.uint8], n: Int): | |
... | |
fn finish[dt: DType = DType.uint64](owned self) -> Scalar[dt]: |
This file contains 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 matplotlib.pyplot as plt | |
def _normalized_experience(data: dict[str, list[int | list[int]]]) -> tuple[int, dict[str, list[int]]]: | |
"""Returns a tuple with latest year and an experience dict with normalised years list""" | |
latest_year = 0 | |
result = {} | |
for topic, years in data.items(): | |
normalised_years = [] | |
for entry in years: | |
if isinstance(entry, list): |
This file contains 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
#!/bin/bash | |
function check_out_remote_module() ( | |
rurl="$1" | |
shift | |
declare -a paths | |
declare -a module_names | |
for var in "$@" | |
do | |
IFS="=" |
This file contains 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 Bit import bit_length | |
from String import String | |
from Vector import DynamicVector, UnsafeFixedVector | |
from List import VariadicList | |
struct FibyTree[T: AnyType, cmp: fn(T, T)->Int, to_str: fn(T) -> String]: | |
alias Union = 0 | |
alias Intersection = 1 | |
alias Difference = 2 | |
alias SymetricDifference = 3 |
This file contains 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 DType import DType | |
from Functional import vectorize | |
from Pointer import DTypePointer | |
from String import String, ord | |
from TargetInfo import dtype_simd_width | |
alias simd_width_u8 = dtype_simd_width[DType.ui8]() | |
let dna = "CAAGAACCAAGATAACACTCATCGTTTACTTCTTACCCGTGCCAATTCGTATTACAAACGAAACCGTGTGGGCCATGTTCGTTATCCGAGGCCCCTTCAATTACTCGTCACTAGTGACCGTCGCTACTATGCCGTGTCCATGATATTACATCAAGACAATGAGATACGAAACGACAGCTGTTCCTACGCCTCGCGAGGGGTTCTACCCCTGAGCCGTGGGAACAGGCCGTCCGACGATCTTCAAGTGTTAAAGCTAGAAAACTTGATCAGAGAACAGTGACAATCCGGTGCAATTAGGGCGCTTCTAGCAAAGTCTTGACGGTTGACATGCTATTCTACCGGCGCAGGTTGCTTGAATGCGCGGGAGTTTTAAGCTCCTCTGTCACGCCATGCCCCCTGCAGTAGCTCACCAGCAAGAAGTTGGCTTAATATACCTGGTAGGAACGTTTGGTTAAACTTCTTTCCCTCTTCTTATACCGATGACACCTACCAATTACGGTCGGCCCGCCCGTGATCCAAACAGGCCTTAATCTTCCAATAATTCAATATGTGTGTGGCTTACAGGAGTCGAATATTTATAAGTGCATTCCTGCCTTCGCTGTTGCGATTTATAGCATCTTATGGTGGCGCAGGGCAACACTTAAAAGGGAGCCAACATGAGTTTCTAGCGTCAGGCACTGCCCTGAGGTAAAGGAATACCTGTTCGATACTATGAGGCGAGATCGCCCCACCTTAAAACAGAAAGACGGTAACGGTCCCTAGCCATTTCCTTATTGCGTACGAGATTATGGAACGCTT |
This file contains 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
#include <stdio.h> | |
#include <libc.h> | |
typedef struct { | |
int *marking; | |
int *takes; | |
int *puts; | |
int transition_count; | |
int place_count; | |
} PetriNet; |
This file contains 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
func barBellNet() -> PetriNet { | |
let totoalWeightInGram = Place(name: "tototalWeightInGram") | |
let barBellSelected = Place(name: "BarBellSelected") | |
let barBellNotSelected = Place(name: "BarBellNotSelected", initNumberOfTokens: 1) | |
let barBell10Kg = Place(name: "10KgBarBell", initNumberOfTokens: 1) | |
let barBell15Kg = Place(name: "15KgBarBell", initNumberOfTokens: 1) | |
let barBell17_5Kg = Place(name: "17.5_KgBarBell", initNumberOfTokens: 1) | |
let barBell20Kg = Place(name: "20_KgBarBell", initNumberOfTokens: 1) | |
let weight0_5kg = Place(name: "0.5_KgWeight", initNumberOfTokens: 4) | |
let weight1kg = Place(name: "1_KgWeight", initNumberOfTokens: 4) |
This file contains 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
func ticTacToeNet() -> PetriNet { | |
let xTurn = Place(name: "xTurn", initNumberOfTokens: 1) | |
let oTurn = Place(name: "oTurn") | |
let xWin = Place(name: "xWin") | |
let oWin = Place(name: "oWin") | |
let e1 = Place(name: "e1", initNumberOfTokens: 1) | |
let e2 = Place(name: "e2", initNumberOfTokens: 1) | |
let e3 = Place(name: "e3", initNumberOfTokens: 1) | |
let e4 = Place(name: "e4", initNumberOfTokens: 1) |
This file contains 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
1. Motivation | |
This format is designed to allow users pack data together for random access and with space efficiency in mind. | |
2. Internal structure | |
IndexedData (further referenced as idata) can be split up in two general regions: manifest and data. | |
Manifest region contains information needed to identify the number of elements in data region. | |
Plus it contains data neded to extract a signle element out of the data region. | |
Optionaly it can contain a validation key, which can be used to ensure that the data at hand is in fact idata. | |
The data region contains all data items linearly concatenaited to each other. |
NewerOlder