2017-03-01から1ヶ月間の記事一覧
# Rpn.eval "3 1 - 2.1 +" # => 4.1 defmodule Rpn do def eval(expression) do eval(tokenize(expression), []) end defp eval([], [result]), do: result defp eval(["+"|tokens], [rhs, lhs|stack]), do: eval(tokens, [lhs + rhs | stack]) defp eval(["…
練習。 % span.pro :- module(span, [span/2]). span(From, From, [From]) :- !. span(From, To, [From|Span]) :- From < To, From1 is From + 1, span(From1, To, Span), !. % span-test.pro :- include(span). main :- span(1, 10, S), format("~p~n", [S]…