Skip to content

Instantly share code, notes, and snippets.

@einblicker
Created April 10, 2011 01:52
Show Gist options
  • Save einblicker/911972 to your computer and use it in GitHub Desktop.
Save einblicker/911972 to your computer and use it in GitHub Desktop.
methodName = "append"
def makeType(i)
acc = "Z"
i.times{|e|
acc = "S<" + acc + ">"
}
acc
end
def makeArgType(i)
"DepList<'a, " + makeType(i) + ">"
end
def makeRetType(i)
"DepList<'a, " + makeType(i) + ">"
end
body = %Q{new DepList<_, _>(List.append (toList x) (toList y))}
(0..10).each{|i|
(0..10).each{|j|
k = i + j
puts %Q{ static member #{methodName}(x: #{makeArgType(i)}, y: #{makeArgType(j)}): #{makeRetType(k)} = #{body}}
}
}
methodName = "concat"
def makeArgType(i, j)
"DepList<DepList<'a, " + makeType(i) + ">, " + makeType(j) + ">"
end
body = %Q{new DepList<_, _>(map toList x |> toList |> List.concat)}
(1..10).each{|i|
(1..10).each{|j|
k = i * j
puts %Q{ static member #{methodName}(x: #{makeArgType(i, j)}): #{makeRetType(k)} = #{body}}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment