elixir

    2熱度

    1回答

    我有以下的(人爲)代碼: dbconn # this var holds the database connection get_from_cache("missing_key") defp get_from_cache(key) do Cachex.get(:my_cache, key, fallback: &from_db/1) end defp from_db(key)

    0熱度

    1回答

    我有一個元素列表,我使用Enum.chunk_every方法將它轉換爲列表列表。 的代碼是這樣的: matrix = Enum.chunk_every(list_1d, num_cols) Now I want to loop over the matrix and access the neighbors 只需如果我有列表[1,2,3,4,5,6,1,2,3]它被轉換成一個3×3矩陣像:

    1熱度

    4回答

    我有這樣 check_file(url) |>test |> foo TRE功能check_file返回 {:ok,_} or {:error,_} 我有一個模式匹配 def test({:ok,_}) do IO.puts "ok"; end def test({:error,_}) do IO.puts "KO, debug and stop!

    2熱度

    1回答

    我有以下函數定義,我試圖找到一種方法來簡化參數,使它們都是統一的。 def update_user(%User{} = user, %{password: _} = attrs) do attrs = Map.put(attrs, :password_reset_token, nil) update_user(user, attrs, &User.password_change

    0熱度

    1回答

    我正在試圖使用elixir/phoenix的守護者0.14和guardian_db 0.8。不過,我一直運行到下面的錯誤在鉤: [error] #PID<0.983.0> running Api.Endpoint terminated Server: localhost:4000 (http) Request: POST /api/login ** (exit) an except

    1熱度

    1回答

    在Python我有使用「輪詢」對象,其輪詢阻斷等待消息插座和放開毫秒的指定次數後的選項(在殼體下面,1000,在同時真塊): import zmq # now open up all the sockets context = zmq.Context() outsub = context.socket(zmq.SUB) outsub.bind("tcp://" + myip + ":"

    1熱度

    1回答

    我想讓下面的代碼塊返回值不等於0或n。但有時它返回的值等於0. def get_random(n, num) do random = returns some number IO.puts random if random == n or random == 0 do get_random(n, num) end random end

    1熱度

    4回答

    我想從列表a中刪除列表b中找到的元素。 執行此代碼後,列表a正在打印[1,2,3,4]。 defmodule Test do def listing do a = [1,2,3,4] b = [3,4,5,6] Enum.each b, fn elemB -> a = Enum.filter(a, fn(x) -> x != elemB == true

    1熱度

    1回答

    我已經創建了一些phoenix應用程序,並且所有似乎默認情況下都不接受https請求。我收到錯誤[error] Cowboy returned 400 and there are no headers in the connection.。 Http請求按預期返回數據。

    0熱度

    1回答

    使用外生V2.2.6多個協會,鳳凰1.3 我在其中一個用戶可以創建職位的場景,然後其他用戶可以像帖子。用戶通過創建與帖子建立一對多關係,並通過鏈接表與喜歡建立多對多關係。 設置: mix phx.gen.json Account User users name:string mix phx.gen.json Content Post posts title:string content:text