Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning erlang code in native mode
    primarykey
    data
    text
    <p>I cannot run the following code in native mode. The error message is displayed when I try: </p> <blockquote> <p>Warning: this system is not configured for native-code compilation. escript: exception error: no function clause matching test_<em>escript</em>_1383_<em>893414</em>_479613:main([]) (./test, line 5) in function escript:run/2 (escript.erl, line 747) in call from escript:start/1 (escript.erl, line 277) in call from init:start_it/1 in call from init:start_em/1</p> </blockquote> <p>How can I configure my system to run it in native mode?</p> <p>Code: </p> <pre><code>#!/usr/bin/env escript -mode(native). %% to fun faster main([NStr]) -&gt; N = list_to_integer(NStr), IJ = [{I, J} || I &lt;- lists:seq(1, N), J &lt;- lists:seq(1, N)], lists:foreach(fun({I, J}) -&gt; put_data(I, J, true) end, IJ), solve(N, 1, [], 0). solve(N, J, Board, Count) when N &lt; J -&gt; print(N, Board), Count + 1; solve(N, J, Board, Count) -&gt; F = fun(I, Cnt) -&gt; case get_data(I, J) of true -&gt; put_data(I, J, false), Cnt2 = solve(N, J+1, [I|Board], Cnt), put_data(I, J, true), Cnt2; false -&gt; Cnt end end, lists:foldl(F, Count, lists:seq(1, N)). put_data(I, J, Bool) -&gt; put({row, I }, Bool), put({add, I+J}, Bool), put({sub, I-J}, Bool). get_data(I, J) -&gt; get({row, I}) andalso get({add, I+J}) andalso get({sub, I-J}). print(N, Board) -&gt; Frame = "+-" ++ string:copies("--", N) ++ "+", io:format("~s~n", [Frame]), lists:foreach(fun(I) -&gt; print_line(N, I) end, Board), io:format("~s~n", [Frame]). print_line(N, I) -&gt; F = fun(X, S) when X == I -&gt; "Q " ++ S; (_, S) -&gt; ". " ++ S end, Line = lists:foldl(F, "", lists:seq(1, N)), io:format("| ~s|~n", [Line]). </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload