Skip to content

Instantly share code, notes, and snippets.

package ws.graps;
import android.app.Activity;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
(* 名前と成績の組から評価を出力する *)
(* seiseki : string * string -> string *)
let seiseki pair = match pair with
(a, b) -> a ^ " さんの評価は " ^ b ^ " です"
let test1 = seiseki ("たまご", "A") = "たまご さんの評価は A です"
(* x座標とy座標の組からx軸について対称な点の座標を返す *)
(* int * int -> int * int *)
let taisho_x pair = match pair with
(x, y) -> (x, -y)
let test1 = taisho_x (2, 1) = (2, -1)
let test2 = taisho_x (0, 5) = (0, -5)
let test3 = taisho_x (1, 0) = (1, 0)
(* 目的:x座標とy座標の組2つからその中点の座標の組を返す *)
(* float * float -> float * float -> float * float *)
let chuten point1 point2 = match point1 with
(x1, y1) -> (match point2 with
(x2, y2) -> ((x1 +. x2) /. 2.0, (y1 +. y2) /. 2.0))
let test1 = chuten (0.0, 0.0) (2.0, 2.0) = (1.0, 1.0)
let test2 = chuten (-3.0, -2.0) (4.0, 6.0) = (0.5, 2.0)
let test3 = chuten (-5.0, -3.0) (-4.0, -8.0) = (-4.5, -5.5)
type book_t = {
title: string;
author: string;
publisher: string;
price: int;
isbn: string;
}
let book1 = {title = "head first java"; author = "Kephy"; publisher = "Oreilly"; price = 4800; isbn = "4-87311-279-6"}
let book2 = {title = "angougijutsunyuumon"; author = "Yuhki Hiroshi"; publisher = "Softbank"; price = 3000; isbn = "978-4-7973-5099-9"}
#!/usr/bin/perl
use strict;
use warnings;
use encoding 'utf-8', STDOUT => 'utf-8';
use WWW::Mechanize;
my $mech = new WWW::Mechanize;
my $username = 'username';
my $password = 'password';
@grapswiz
grapswiz / core.js
Created May 20, 2011 17:33
wiki format to html
(function(global) {
global.onload = function() {
ajaxRequest('in.txt', function(input) {
var text = '';
input = input.split('\n');
for (var i = 0; i < input.length; i++) {
if (input[i] != '') {
text += format(input[i]);
}
function ajaxRequest(url, callback) {
var req = new XMLHttpRequest();
req.open('GET', url, true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
callback(req.responseText);
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
struct servent * getService(char *, char *);