Skip to content

Instantly share code, notes, and snippets.

View Liudx1985's full-sized avatar
😇
All repos are moved to https://gitee.com/liudx1985/ Permanently!

Liudx Liudx1985

😇
All repos are moved to https://gitee.com/liudx1985/ Permanently!
View GitHub Profile
import numpy as np
from pylab import *
raw = np.array([
[0, 0.0],
[0.15708, 0.156313],
[0.314159, 0.308879],
[0.471239, 0.453952],
[0.628319, 0.587785],
[0.785398, 0.706871],
@Liudx1985
Liudx1985 / amb.ss
Last active August 29, 2015 14:00
amb in scheme (call-with-current-continuation)
#lang r5rs
(define amb-fail '*)
(define initialize-amb-fail
(lambda ()
(set! amb-fail
(lambda ()
(display "amb tree exhausted")))))
(initialize-amb-fail)
@Liudx1985
Liudx1985 / n-queue.ss
Created April 26, 2014 02:41
amb usage.
;;;;;;;;;;
(load "amb.ss")
;(define (debug e) #f)
(define debug
(lambda (e)
(cond ((list? e)
(for-each display e))
((string? e)
(display e)))))
@Liudx1985
Liudx1985 / interpreter.scm
Created May 23, 2014 09:05
basical scheme interpreter
#lang racket
;;; 以下三个定义 env0, ent-env, lookup 是对环境(environment)的基本操作:
;; 空环境
(define env0 '())
;; 扩展。对环境 env 进行扩展,把 x 映射到 v,得到一个新的环境
(define ext-env
(lambda (x v env)
(cons `(,x . ,v) env)))
#lang racket
; applicative-order Y-combinator.
; Y: The function that takes a function f and returns f (f (f (f (···))))
(define Y
(lambda (le)
((lambda (f) (f f))
(lambda (f)
(le (lambda (x) ((f f) x)))))))
@Liudx1985
Liudx1985 / hash_2_3.cxx
Last active August 29, 2015 14:05
hash_pair
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
// 双射函数
// proven :
// as
@Liudx1985
Liudx1985 / Binomial.cxx
Created August 12, 2014 08:34
计算二项式系数C(n,k)
#include <vector>
#include <iostream>
#include "d:/workspace/dxh/testUlt.h"
using namespace std;
//计算二项式系数C(n,k)
int Binomial(int n, int k) {
int result[n + 1][k + 1];
for(int i = 0; i <= n; ++i) //按行来填矩阵
{
@Liudx1985
Liudx1985 / clear_dir.py
Last active August 29, 2015 14:05
work file-directory ,clear or zip files.
# -*- coding:UTF-8 -*-
#!/usr/bin/env python
'''
Clear the directory using filter
'''
import os.path
import sys,os
import stat
import re
@Liudx1985
Liudx1985 / fibonacci.
Last active August 29, 2015 14:05
Fibonacci性质
Fibonacci f(n+1)=f(n)+f(n-1) n >= 1
1. sum(f(n)^2) = f(n)*f(n+1)
证明如下,面积之和相等
# 绘图代码如下
import matplotlib.pyplot as plt
from matplotlib.path import Path
import matplotlib.patches as patches
@Liudx1985
Liudx1985 / C++.sublime-build
Created September 3, 2014 02:37
C++.sublime-build for ST3
{
"cmd": ["g++", "-std=c++1y", "${file}", "-O2", "-Wall", "-o", "${file_path}/${file_base_name}"], // For GCC On Windows and Linux
//"cmd": ["CL", "/Fo${file_base_name}", "/O2", "${file}"], // For CL on Windows Only
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.c, source.c++",
"variants":
[
{