-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ae44d0
commit e4dc591
Showing
18 changed files
with
301 additions
and
63 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# TODO: Too slow to be published. Probably needs Maps/Sets/Vectors/sth. | ||
|
||
:import std/Combinator . | ||
:import std/Char C | ||
:import std/Math . | ||
:import std/List . | ||
|
||
# very slow but elegant | ||
de-bruijn y [[[C.?infix? (take 0 1) ~1 case-end case-rec]]] | ||
case-rec max-by (compare ⋔ length) ([3 (0 : 2) 1] <$> (C.?nub 1)) | ||
case-end drop 0 1 | ||
|
||
:test (de-bruijn "abcd" (+2)) ("dccaadbbacbdabcd") | ||
|
||
main [[0]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:test ([[0]]) ([[1]]) | ||
|
||
main [[0 0] [0 0]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
first [0 [[0]]] | ||
|
||
second [first [[1]]] | ||
|
||
:test (second) ([[[[0]]]]) | ||
|
||
main [[0]] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
:import std/Combinator . | ||
:import std/Math . | ||
:import std/List . | ||
|
||
luhn number→list → reverse → check → (\mod (+10)) → zero? | ||
check y [[[[0 [[[6 \5 (4 + (5 odd even)) 1]]] 1]]]] k (+0) | ||
odd 2 | ||
even digit-sum (2 ⋅ (+2)) | ||
|
||
:test (luhn (+61789372994)) ([[1]]) | ||
:test (luhn (+49927398716)) ([[1]]) | ||
:test (luhn (+49927398717)) ([[0]]) | ||
:test (luhn (+1234567812345678)) ([[0]]) | ||
:test (luhn (+1234567812345670)) ([[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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
:import std/List . | ||
:import std/Math . | ||
|
||
arr (+1) : ((+2) : ((+3) : {}(+4))) | ||
|
||
main [∑arr : ∏arr] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
:import luhn_test_of_credit_card_numbers . | ||
|
||
:import std/Number/Conversion . | ||
:import std/Combinator . | ||
:import std/String . | ||
:import std/Char . | ||
:import std/Logic . | ||
:import std/Number . | ||
|
||
# verifies ISIN format | ||
format? [len ⋀? country ⋀? security ⋀? checksum] | ||
len (length 0) =? (+12) | ||
country all? uppercase? (take (+2) 0) | ||
security all? (φ or? uppercase? numeric?) (take (+9) (drop (+2) 0)) | ||
checksum numeric? _0 | ||
|
||
# performs luhn test | ||
checksum? (map (from-base36 → number→string)) → concat → string→number → luhn | ||
from-base36 binary→ternary → [(0 - (0 ≥? (+65) ((+65) - (+10)) (+48)))] | ||
|
||
# performs format and checksum test | ||
validate φ and? format? checksum? | ||
|
||
:test (validate "US0378331005") (true) | ||
:test (validate "US0373831005") (false) | ||
:test (validate "U50378331005") (false) | ||
:test (validate "US03378331005") (false) | ||
:test (validate "AU0000XVGZA3") (true) | ||
:test (validate "AU0000VXGZA3") (true) | ||
:test (validate "FR0000988040") (true) |
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
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
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
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
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
Oops, something went wrong.