Skip to content

Instantly share code, notes, and snippets.

@314maro
314maro / e.html
Last active August 29, 2015 14:20
電気力線的なやつ
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<script>
function stepRK(h,f,x,y) {
var tmp=[],k1=[],k2=[],k3=[],k4=[];
var n = f.length; // n == f.length == y.length
for (var i=0;i<n;i++) tmp[i] = y[i];
for (var i=0;i<n;i++) k1[i] = h*f[i](x, tmp);
@314maro
314maro / physics.html
Last active August 29, 2015 14:19
下の入力欄はまだ機能つけてない
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8" />
<script>
function stepRK(h,f,x,y) {
var tmp=[],k1=[],k2=[],k3=[],k4=[];
var n = f.length; // n == f.length == y.length
for (var i=0;i<n;i++) tmp[i] = y[i];
for (var i=0;i<n;i++) k1[i] = h*f[i](x, tmp);
<!DOCTYPE html>
<html lang="ja">
<head>
<script>
function rungekutta(n,xn,f0,f1,x0,y00,y10) {
var h = (xn - x0) / n;
var xi = x0, obj = [y00,y10];
function step(x,obj) {
var y0 = obj[0], y1 = obj[1];
@314maro
314maro / rungekutta.html
Last active August 29, 2015 14:18
理屈わからんが解けてるようだ
<!DOCTYPE html>
<html lang="ja">
<head>
<script>
function rungekutta(n,xn,f,x0,y0) {
var h = (xn - x0) / n;
var xi = x0, yi = y0;
function step(x,y) {
var k1 = f(x, y),
k2 = f(x+h/2, y+h*k1/2),
@314maro
314maro / canvas.html
Last active August 29, 2015 14:18
jsの練習
<!DOCTYPE html>
<html>
<head lang="ja">
<meta charset="UTF-8" />
<title>こんにちは世界</title>
<script>
'use strict';
var canvas, ctx;
window.onload = function () {
canvas = document.getElementById('canvas');
@314maro
314maro / m.c
Last active March 23, 2016 17:28
行列 いろいろ手抜きした
#include <stdio.h>
#include <stdlib.h>
// Reference: R(mat,i,j) -> mat[i][j]
#define R(mat,i,j) (mat).m[(i)*(mat).c+(j)]
typedef struct {
int r, c;
double *m;
} mat;
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
////////////////////////////////////////////////////////////////
// types
////////////////////////////////////////////////////////////////
enum exp_tag {
exp_var, exp_lam, exp_app
@314maro
314maro / a.hs
Created August 31, 2014 11:52
λ見ていて思いついたフラクタル いまいちな見た目 L-systemのを書いた時のコードを使った 今見ると挙動がバグっぽい
import Data.Maybe (fromMaybe)
data Turtle = Turtle { turtleX :: Double
, turtleY :: Double
, turtleD :: Double
, turtleLine :: [(Double,Double,Double,Double)]
} deriving Show
moveTurtle a c t
| c == '+' = turn a t
l=[".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."];toM=fmap unwords.mapM(`lookup`zip['A'..]l);toA=mapM(`lookup`zip l['A'..]).words
main=maybe(return())putStrLn$toA"... --- ..."
-- or
-- main=maybe(return())putStrLn$toM"HOGE"
@314maro
314maro / queue.c
Created July 19, 2014 09:20
雑な実装のスタックとキュー 下手なこと(空に対しての操作とか)するとバグるはず
#include <stdio.h>
#include <stdlib.h>
typedef long item;
typedef struct {
int max_size;
int head, length;
item *items;
} queue;