Instantly share code, notes, and snippets.

🎯
Focusing

# LuckyKoala

🎯
Focusing
• Sort options
Last active Nov 2, 2018
SICP 4.1，Lisp解释器实现（包含习题解答）
View evaluator.scm
 (define (eval exp env) ((analyze exp) env)) (define (analyze exp) (cond ((self-evaluating? exp) (analyze-self-evaluating exp)) ((quoted? exp) (analyze-quoted exp)) ((variable? exp) (analyze-variable exp)) ((assignment? exp)
Last active Jun 18, 2018
6174是黑洞数（亦称为卡布列克常数，任何非四位相同数字，只要将数字重新排列，组合成最大的值和最小的数再加以相减，重复以上步骤，七次以内就会出现6174。例如：8045，8540-0458=8082，8820-0288=8532，8532-2358=6174。）
View 6174.c
 #include #include #include "mpi.h" //------Common base------ typedef int bool; enum { false, true }; //------Define a struct of four digit number------ typedef struct { int thousand;
Last active Jun 18, 2018
MonteCarlo方法求PI，内置两个样本实验。Cesaro每次选取两个随机数求其最大公约数，若为1则计数器加1，最终计数器的值除以总的尝试次数近似于6/PI*PI。Area则是在以(0,0)为中心点，以1为边长的正方形中随机抽取一个坐标点，若其位于以(0,0)为圆心，1为半径的圆中，则计数器加1，最终计数器的值除以总的尝试次数近似于PI/4。
View monte_carlo.c
 #include #include #include #include #include "mpi.h" //------Common base------ typedef int bool; enum { false, true };
Last active May 2, 2018
Javascript implementation for SICP Chapter 2.
View sicpDataAbstraction.js
 sicp = (function() { //-----Base implementation------ //Primitive procedure let cons = (x,y) => [x,y]; let car = (pair) => pair[0]; let cdr = (pair) => pair[1]; //Nil definition let nil = []; let isNil = (obj) => obj==null || (Array.isArray(obj) && obj.length==0); //Helper procedure to build, extract, compare and print list
Created Mar 31, 2018

View check_connection.sh
 #!/bin/bash # 来源 [GitHub](https://github.com/funet8/shell/blob/master/check_internet.sh) #网络检查的脚本，当你不能上公网时，则直接执行这个脚本 # 部分注释由iwar添加 #输入网卡和局域网路由器IP read -p "请输入您公网网卡名称：（如:eth0）" ethx read -p "请输入您的局域网路由器IP：（如:192.168.1.1）" netip
Last active Mar 25, 2018
int array[8]; &array 的类型是 int (*)[8]
View deference_pointer.c
 #include int main(void) { int array[8] = {10,11,12,13,14,15,16,17}; int *p = array; int *q = &array; //提示不兼容的类型，这里其实是转换了指针类型 int (*z)[8] = &array; printf("the size of array: %ld, the size of &array: %ld\n", sizeof(array), sizeof(&array));
Last active Mar 21, 2018
Linux下在Minecraft里输入中文的辅助脚本
View minecraft_input.sh
 #!/bin/bash -e #用法: minecraft_input.sh [auto] #加上参数auto意味着脚本会自动将接收到的文字发送到输入框中并发送 #如果是在告示牌上使用，不需要带参数 #打开zenity对话框 chars=\$(zenity --title 中文输入 --text 中文输入 --entry 2>/dev/null) #检查是否有参数 if [ \$1 == "auto" ] then
Created Jun 27, 2017
Abou Seven Languages In Seven Weeks Io,Day 2. Use js as extension name so the code can be highlighted.
View deepsum.js
 //For 3.3 //Create a nested list li := list(1,2,3,list(3,4),"str") //Flatten and only operate on Number and then sum them List deepsum := method( self flatten select(isKindOf(Number)) sum ) li deepsum
Last active Oct 3, 2017
Simple plugin for Minecraft
View AntiAutoFishing.java
 package tech.zuosi.plugin.antiautofishing; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.java.JavaPlugin;
Created May 30, 2017