Top Level Namespace

Defined Under Namespace

Classes: Proc, String

Instance Method Summary collapse

Instance Method Details

#gesoObject

ゲソコンビネータ (K) じゃなイカ?



23
24
25
# File 'lib/ikamusume.rb', line 23

def geso
  proc {|x| proc {|y| x } }
end

#ika?Boolean

イカ娘!コンビネータ (I) じゃなイカ?

Returns:

  • (Boolean)


28
29
30
# File 'lib/ikamusume.rb', line 28

def ika?
  proc {|x| x }
end

#shinryaku!Object

侵略!コンビネータ (S) じゃなイカ?



18
19
20
# File 'lib/ikamusume.rb', line 18

def shinryaku!
  proc {|x| proc {|y| proc {|z| x <= z <= (y <= z) } } }
end

#unlambda_to_ikamusume!(src, keywords = [["侵略!", 5], ["ゲソ", 4], ["イカ娘!", 7]]) ⇒ Object

Unlambda も侵略してやるでゲソ



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/ikamusume.rb', line 42

def unlambda_to_ikamusume!(src, keywords = [["侵略!", 5], ["ゲソ", 4], ["イカ娘!", 7]])
  PrettyPrint.format("", 0) do |pp|
    translate = proc do |need_paren|
      ch = src.slice!(0, 1)
      case ch
      when "`"
        if need_paren
          pp.group(2, "(", ")") do
            translate[false]
            pp.text " <="
            pp.breakable
            translate[true]
          end
        else
          translate[false]
          pp.text " <="
          pp.breakable
          translate[true]
        end
      when "s" then pp.text *keywords[0]
      when "k" then pp.text *keywords[1]
      when "i" then pp.text *keywords[2]
      when "." then pp.text src.slice!(0, 1).dump
      when "r" then pp.text '"\n"'
      when "#" then src.slice!(/.*/); translate[need_paren]
      when /\A\s\z/ then translate[need_paren]
      when nil then raise "unexpected termination"
      else raise "unimplemented instruction: %p" % ch
      end
    end
    translate[false]
  end
end