Skip to content

Instantly share code, notes, and snippets.

@xwu
xwu / user-experience-of-new-integer-protocols.md
Last active August 3, 2017 02:07
Notes on the user experience of new integer protocols

Notes on the user experience of new integer protocols

Xiaodi Wu
June 17, 2017

Introduction

The design, re-design, and implementation of [SE-0104][1], a proposal to revise integer protocols in Swift, is now largely complete in shipping previews of Swift 4. As an exercise, I have used the new APIs to develop a [set of additional numeric facilities][2]. Here are some insights gained from that experience--and from two unpublished exercises to implement a BigInt type (one from scratch, one wrapping GMP)--as well as suggestions for improvement.

@xwu
xwu / utn28-default-operators.md
Last active October 10, 2017 23:50
UTN28 Default Operators

Extracted from UTN28

"The following table gives the default math keywords, their target characters and codes along with spacing and linear-format build-up properties."

Omitted from the original table are operands, enclosures, spaces, big/long variants, and non-NFKC characters. Three characters that default to their emoji variants on iOS, and one related character, are excised.

Keyword Glyph Code Spacing LF Property
pm ± U+00B1 unary/binary unary/binary
times × U+00D7 binarynsp normal
@xwu
xwu / swift-default-operators.md
Last active October 12, 2017 01:46
Swift Default Operators
Glyph Code Description
! U+0021 EXCLAMATION MARK
% U+0025 PERCENT SIGN
& U+0026 AMPERSAND
* U+002A ASTERISK
+ U+002B PLUS SIGN
- U+002D HYPHEN-MINUS
/ U+002F SOLIDUS
< U+003C LESS-THAN SIGN
@xwu
xwu / NNNN-rename-sequence-elements-equal.md
Last active November 12, 2017 05:34
Rename Sequence.elementsEqual

Rename Sequence.elementsEqual

  • Proposal: SE-NNNN
  • Authors: Xiaodi Wu
  • Review Manager: TBD
  • Status: Awaiting review

During the review process, add the following fields as needed:

@xwu
xwu / dna3bit.py
Created March 13, 2022 20:50
Command line utility for encoding and decoding SEQC 3-bit representations of DNA
import argparse
import sys
from functools import reduce
from typing import Iterator
def encode(raw: str) -> int:
return reduce(lambda x, y: x * 8 + y,
map(lambda x: x % 32 % 5 + 3, raw.encode()))
def _decode(cooked: int) -> Iterator[int]: