Twigでlispを作ってるんだナ! (9レス)
1-

1: 07/06(土)22:03 ID:pcJPW2j0N(1) AAS
{% macro evaluate(expression) %}
{% set result = _self._evaluate(expression|trim) %}{{ result }}
{% endmacro %}
{% macro _evaluate(expression) %}
{% set num = 1 %}
{# 前後の空白を取り除く #}{% set expr = expression|trim %}
{# カッコで挟まれた部分を識別する #}{% if expr starts with '(' and expr ends with ')' %}
{# 文字の部分だけをexprに代入 #}{% set expr = expr|slice(1, -1)|trim %}
{% endif %}
{# 空白で配列化 #}{% set components = expr|split(' ') %}
省20
2: 07/07(日)12:07 ID:Z9WWCnLov(1/8) AAS
{% macro evaluate(expression) %}{% set result = _self._evaluate(expression|trim) %}{{ result }}{% endmacro %}
{% macro _evaluate(expression) %}{% set num = 1 %}
{% set expr = expression|trim %}{% set expr = expr|split(')(') %}{% set expra = expr[0] %}
{% set expra = expra|trim('(')|trim(')')|trim %}{% set components = expra|split(' ') %}
{% set operator = components[0] %}{% set operands = components[1:] %}
{% if operator == '+' %}{{_self._keisan(operator,operands)}}
{% elseif operator == '-' %}{{_self._keisan(operator,operands)}}{% elseif operator == '*' %}{{_self._keisan(operator,operands)}}
{% elseif operator == '/' %}{{_self._keisan(operator,operands)}}{% elseif operator == 'if' %}{% set a = operands[0]|trim('(') %}
{% set b = operands[1] %}{% set c = operands[2]|trim(')') %}{% if a == 'eq?' %}{% if b == c %}{% set result = "true" %}
{% set expra = expr[1] %}{% set expra = expra|trim('(')|trim(')')|trim %}{% set components = expra|split(' ') %}
省7
1-
あと 7 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.258s*