#extern修飾子の意味
外部で定義される変数であることを宣言するための修飾子
ただし
extern修飾子を付けて変数aを宣言する => 変数aは外部定義される
は成り立つが、その逆
| # run on irb as follows. | |
| # $ irb -r './type0.rb' | |
| # irb> e [:define, :f, [:lambda, [:v], ["+", :v, 1]]] | |
| # irb> e [:f 1] | |
| # => 2 | |
| # ... | |
| module Type0 | |
| Environment = Struct.new(:parent, :hash) | |
| Lambda = Struct.new(:env, :params, :exp) |
#extern修飾子の意味
外部で定義される変数であることを宣言するための修飾子
ただし
extern修飾子を付けて変数aを宣言する => 変数aは外部定義される
は成り立つが、その逆
| require 'test/unit' | |
| require './tiny_frp.rb' | |
| module TinyFRP | |
| module UnitTest | |
| module Util | |
| def lift(&proc) | |
| TinyFRP::Lift.new(&proc) | |
| end |
| import qualified Data.ByteString as B | |
| import GHC.IO.Handle | |
| import System.Process | |
| import System.IO | |
| type Packet = B.ByteString | |
| pktsize = 188 | |
| main = do |
| {-# LANGUAGE Arrows #-} | |
| import qualified FRP.Yampa as Y | |
| type Inp = (String, String) | |
| type Out = String | |
| main = do | |
| rh <- Y.reactInit initIO act sf | |
| loop rh |
| class RecordInstance | |
| attr_reader :klass, :members | |
| def initialize(klass, hash) | |
| unless klass.members.all?{|name, type| hash.has_key?(name) && hash[name].is_a?(type)} | |
| raise "Instance initialization error!!" | |
| end | |
| @klass = klass | |
| @members = klass.members.keys.inject({}){|acc, name| acc.merge(name => hash[name])} | |
| end |
| #include <iostream> | |
| #include <cstdio> | |
| #include <vector> | |
| #include <algorithm> | |
| #include <cstring> | |
| #include <utility> | |
| using namespace std; | |
| typedef vector<vector<char> > B; | |
| typedef pair<int, int> P; |
| #!/usr/bin/env ruby | |
| # -*- mode: ruby -*- | |
| require 'net/http' | |
| require 'uri' | |
| require 'nokogiri' | |
| module AOJ | |
| extend self | |
| def get(id) |
| object_files = \ | |
| frp_sample.o \ | |
| frp_sample_lib.o | |
| .SUFFIXES : .c | |
| frp_sample: $(object_files) | |
| gcc -Wall -o frp_sample $(object_files) | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| typedef struct ReactiveInt* ReactiveInt; | |
| struct ReactiveInt | |
| { | |
| int n; | |
| int (*operator)(int, int); | |
| ReactiveInt left, right; |