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