Yaw and erlang ray files in ebin

I am having problems when I have integers and floating point numbers in form messages and get them in my ebin file, where I have ray files. Hope someone can help me.

npower.yaws

   <erl>
kv(K,L) ->
{value, {K, V}} = lists:keysearch(K,1,L), V.        
out(A) ->
L = yaws_api:parse_post(A),
N = kv("number", L),
    npower62:math3(N).
    </erl>

npower62.erl compiled for the ray file
module (npower62).

-export ([math3 / 1]).

math3 ([N]) →
      Number = N,
      Nsquare = Number * Number,
      {html, io_lib: format ("square ~ c = ~ w", [N, Nsquare])}.

3 = 2601

3 = 9
  Number = list_to_integer (atom_to_list (N)) ( )
  Number = list_to_float (atom_to_list (N)) ( )
  Number = list_to_integer (N) ( )

+3
1

-, , math3/1:

-module(npower62). 
-export([math3/1]). 

math3(N) when is_number(N) -> 
  N2 = N * N,
  io_lib:format("square of ~p = ~p", [N, N2]).

, . , , N. , , io_lib:format/2, , . man -erl io.

:

<erl>
  kv(K,L) ->
      proplists:get_value(K, L, none).

  out(A) ->
    L = yaws_api:parse_post(A),
    N = kv("number", L),
    none =/= N, %% Assert we actually got a value from the kv lookup

    %% Insert type mangling of N here so N is converted into an Integer I
    %% perhaps I = list_to_integer(N) will do. I don't know what type parse_post/1
    %% returns.

    {html, npower62:math3(I)}
</erl>

, kv/2 proplists. kv/2 {value, {K, V}}, math3/1. proplists:get_value/3 V. , {html,...} . , npower62 , , .

, list_to_integer (N). - error_logger:info_report([{v, N}]) INFO REPORT , N.

TL; DR: , . , , , , , . .

, npower62:math3/1 erl. , , , .

0

Source: https://habr.com/ru/post/1778830/


All Articles