★Twigでlispを作ってるんだナ! (9レス)
上下前次1-新
8: 07/07(日)19:34 ID:Z9WWCnLov(7/8) AAS
{% else %}{% set result = "false" %}{% endif %}{% elseif a == 'neq?' %}{% if b != c %}{% set result = "true" %}{% set expra = expr[1] %}
{% set expra = expra|trim('(')|trim(')')|trim %}{% set components = expra|split(' ') %}{% set operator = components[0] %}
{% set operands = components[1:] %}{{_self._keisan(operator,operands)}} {% else %}{% set result = "false" %}{% endif %}{% endif %}{% else %}
{% set result = "Unknown operation" %}{% endif %}{{ result }} {% endmacro %}{% macro _keisan(operator,operands) %}{% set num = 1 %}
{% if operator == '+' %}{% set result = operands|reduce((acc, item) => acc + item|number_format) %}{{ result }} {% elseif operator == '-' %}
{% for item in operands %}{% if num == 1 %}{% set totalPrice = item|number_format %}{% set num = num + 1 %}{% else %}{% set num = num + 1 %}
{% set totalPrice = totalPrice - item|number_format %}{% endif %}{% if num == operands|length + 1 %}{{ totalPrice }} {% endif %}{% endfor %}
{% elseif operator == '*' %}{% set result = operands|reduce((acc, item) => acc * item|number_format,1) %}{{ result }} {% elseif operator == '/' %}
{% for item in operands %}{% if num == 1 %}{% set totalPrice = item|number_format %}{% set num = num + 1 %}{% else %}{% set num = num + 1 %}
{% set totalPrice = totalPrice / item|number_format %}{% endif %}{% if num == operands|length + 1 %}{{ totalPrice }} {% endif %}{% endfor %}
{% elseif operator == 'print' %}{% for item in operands %}{{ operands[p|number_format] }} {% set p = p + 1 %}{% endfor %}{% endif %}{% endmacro %}
上下前次1-新書関写板覧索設栞歴
あと 1 レスあります
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル
ぬこの手 ぬこTOP 0.002s