Reference: https://docs.julialang.org/en/v1/manual/types/index.html
Relationship between super/sub types:
Any >: Number >: Real >: Integer >: Signed >: Int === Int64 >: Function >: getfield(Main, Symbol(”##1##2”)) >: typeof(f)
Reference: https://docs.julialang.org/en/v1/manual/types/index.html
Relationship between super/sub types:
Any >: Number >: Real >: Integer >: Signed >: Int === Int64 >: Function >: getfield(Main, Symbol(”##1##2”)) >: typeof(f)
""" | |
:func:`include` works like Julia :func:`include` for code splitting. | |
When a Python code is too large to maintain, it could be split into files, | |
as well as done in Julia code. | |
:func:`include` works as Julia built-in :func:`include` to merge code | |
with given relative path. It is done with Python built-in :func:`exec` | |
and :mod-attr:`__file__` | |
""" |
# Julia 1.0.3 | |
buzzwords = ( | |
"自經區", "自貿區", | |
"摩天輪", "愛情摩天輪", "愛情產業鏈", | |
"發大財", "愛河的水甘甘", "選總統", | |
"迪士尼", | |
"F1", "F1賽車場", "F1 賽車場", | |
"賭馬", "賽馬", | |
"九二共識", "一中各表", "一國兩制", "兩岸統一", | |
) |
# Python unittest | |
class TestTransactionControl(unittest.TestCase): | |
def test_create_commit(self): | |
id_ = self.create() | |
self.should_have_this_record(id_) | |
def test_create_rollback(self): | |
self.request_start() | |
id_ = self.generate_id() | |
self.request_fail() |
module T where | |
import Test.QuickCheck | |
import Test.DocTest | |
-- | | |
-- >>> grouping [21,5,0,16,21,23] | |
-- [[21],[5,0,16],[21],[23]] | |
-- | |
-- >>> all (\g -> sum g >= 21) [[21],[5,0,16],[21],[23]] |
f = print | |
i = 1 | |
while i<9999: | |
f(i) | |
i += 1 |
# ref: https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life#Examples_of_patterns | |
# Python 3.6 | |
import collections | |
import typing | |
#import asyncio | |
Point = collections.namedtuple('Point', ['x', 'y']) | |
Point.__add__ = lambda self, other: Point(self.x + other.x, self.y + other.y) | |
// ref: https://doc.rust-lang.org/rust-by-example/custom_types/enum/testcase_linked_list.html | |
#include <stdio.h> | |
#include <stdlib.h> | |
enum NodeType { Cell, Nil }; | |
typedef struct LinkedList LinkedList; | |
typedef struct NodeCell { | |
int car; |
r""" | |
>>> L = [1,2,3,4,5,6,7] | |
Imperative | |
========== | |
>>> def f(L, c): | |
... matrix = [] | |
... row = [] |
def natural_cmp(a, b): | |
''' | |
Usage: | |
list.sort(cmp=util.natural_cmp) | |
or | |
sorted_list = sorted(list, cmp=util.natural_cmp) | |
Sorts by alpha and then by numeric hence lists like: | |
row1 | |
row2 |