{{ message }}

Instantly share code, notes, and snippets.

# Li Yaolastland

Created Aug 11, 2012

View BeyesianAvg.py
 # -*- coding=utf-8 -*- import collections # Usage: # 我的做法是把WordsDetector.py里的结果输出到文件， # 然后把文件名放到下面的names列表中，运行本程序。 names = ['name0', 'name1', 'name2',
Created Mar 25, 2017
View clock.c
 #include #include #define MAX_SQUARE 57521883 #define C1 4617 #define C2 73 #define C3 36936 #define C4 262657 #define C5 2134536 #define C6 16810048
Created Sep 4, 2016
Dependently Typed Vector in Scala
View Vec.scala
 package dependent import scala.language.implicitConversions import shapeless._, shapeless.nat._ object Vector { trait Vec[+A, N <: Nat] case object Nil extends Vec[Nothing, _0]
Created Sep 4, 2016
View Vec.hs
 {-# LANGUAGE GADTs, DataKinds, KindSignatures, TypeFamilies #-} module Vector where data Nat = Z | S Nat data Vec :: * -> Nat -> * where Nil :: Vec a Z Cons :: a -> Vec a n -> Vec a (S n)
Created Aug 10, 2016
Scala-Forklift-CLA
View gist:1a1aa20c977567bc2e8aeb22e41017ce
 I, the contributor, agree to licence my contributions to the Scala-Forklift project under the terms of the Apache 2.0.
Created Apr 6, 2012
swap two float variables via xor
View FloatSwap.cc
 #include void swap(int & a, int & b) { a = a ^ b; b = a ^ b; a = a ^ b; } int main()
Created Dec 20, 2012
The built-in function "sum" of Python 2.7 does run faster. But it's not true in PyPy.
View SumTest.py
 import itertools # tstime(https://bitbucket.org/gsauthof/tstime) is used to measure the performance. # OS: Archlinux 3.6.10-1 # Python Version: 2.7.3 # PyPy Version: 2.0.0-beta1 c = 0 for (i, j) in itertools.product(range(10000), repeat=2): c += i * j
You can’t perform that action at this time.