मैं अमृत के लिए नया हूं और मैं वर्तमान में सी ++ से अमृत के लिए एक एल्गोरिथ्म को फिर से लिख रहा हूं।

मैं एक समानांतर तरीके से एक रिकर्सन को कॉल करना चाहता हूं। अंत में सभी परिणामों को एक साथ जोड़ा जाना चाहिए।

मैंने दस्तावेज़ों में कार्य की जांच की, क्योंकि सी ++ में मौजूद चीज़ों के समान कुछ है। लेकिन दुर्भाग्य से मैं और आगे नहीं बढ़ सकता।

मेरे कोड के साथ मुझे निम्नलिखित अपवाद मिलते हैं:

13:22:31.158 [error] GenServer #PID<0.964.0> terminating
** (Protocol.UndefinedError) protocol Enumerable not implemented for {:cont, {:cont, %{}}} of type Tuple, Flow attempted to convert the stage accumulator into events but failed, to explicit convert your current state into events use on_trigger/2. This protocol is implemented for the following type(s): Flow, Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Range, Stream
    (elixir 1.10.3) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir 1.10.3) lib/enum.ex:141: Enumerable.reduce/3
    (elixir 1.10.3) lib/enum.ex:3383: Enum.reverse/1
    (elixir 1.10.3) lib/enum.ex:2984: Enum.to_list/1
    (flow 1.0.0) lib/flow/materialize.ex:642: anonymous fn/3 in Flow.Materialize.build_trigger/1
    (flow 1.0.0) lib/flow/map_reducer.ex:87: Flow.MapReducer.done_status/4
    (flow 1.0.0) lib/flow/map_reducer.ex:35: Flow.MapReducer.handle_cancel/3
    (gen_stage 1.0.0) lib/gen_stage.ex:2096: GenStage.noreply_callback/3
Last message: {:DOWN, #Reference<0.1582286220.1330905089.229281>, :process, #PID<0.963.0>, :normal}
State: {%{#Reference<0.1582286220.1330905089.229281> => nil}, %{done?: false, producers: %{#Reference<0.1582286220.1330905089.229281> => #PID<0.963.0>}, trigger: #Function<2.13930487/3 in Flow.Window.Global.materialize/5>}, {0, 12}, {:cont, {:cont, %{}}}, #Function<4.74501935/4 in Flow.Materialize.build_reducer/2>}

13:22:31.158 [error] GenServer #PID<0.948.0> terminating
** (stop) exited in: GenStage.close_stream(%{})
    ** (EXIT) an exception was raised:
        ** (Protocol.UndefinedError) protocol Enumerable not implemented for {:cont, {:cont, %{}}} of type Tuple, Flow attempted to convert the stage accumulator into events but failed, to explicit convert your current state into events use on_trigger/2. This protocol is implemented for the following type(s): Flow, Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Range, Stream
            (elixir 1.10.3) lib/enum.ex:1: Enumerable.impl_for!/1
            (elixir 1.10.3) lib/enum.ex:141: Enumerable.reduce/3
            (elixir 1.10.3) lib/enum.ex:3383: Enum.reverse/1
            (elixir 1.10.3) lib/enum.ex:2984: Enum.to_list/1
            (flow 1.0.0) lib/flow/materialize.ex:642: anonymous fn/3 in Flow.Materialize.build_trigger/1
            (flow 1.0.0) lib/flow/map_reducer.ex:87: Flow.MapReducer.done_status/4
            (flow 1.0.0) lib/flow/map_reducer.ex:35: Flow.MapReducer.handle_cancel/3
            (gen_stage 1.0.0) lib/gen_stage.ex:2096: GenStage.noreply_callback/3
    (gen_stage 1.0.0) lib/gen_stage/stream.ex:160: GenStage.Stream.close_stream/1
    (elixir 1.10.3) lib/stream.ex:1415: Stream.do_resource/5
    (elixir 1.10.3) lib/stream.ex:880: Stream.do_transform/5
    (elixir 1.10.3) lib/enum.ex:605: Enum.count/1
    (pva 0.1.0) langfordSequence.ex:47: anonymous fn/4 in LangfordSequence.langfordSequence_p/2
    (flow 1.0.0) lib/flow/materialize.ex:620: Flow.Materialize."-build_reducer/2-lists^foldl/2-0-"/3
    (flow 1.0.0) lib/flow/materialize.ex:620: anonymous fn/5 in Flow.Materialize.build_reducer/2
    (flow 1.0.0) lib/flow/map_reducer.ex:59: Flow.MapReducer.handle_events/3
Last message: {:"$gen_consumer", {#PID<0.947.0>, #Reference<0.1582286220.1330905090.228864>}, [[1, 0, 0, 0, 0, 1, 0, 0], [0, 1, 0, 0, 0, 0, 1, 0], [0, 0, 1, 0, 0, 0, 0, 1]]}
State: {%{#Reference<0.1582286220.1330905090.228864> => nil}, %{done?: false, producers: %{#Reference<0.1582286220.1330905090.228864> => #PID<0.947.0>}, trigger: #Function<2.13930487/3 in Flow.Window.Global.materialize/5>}, {0, 12}, %{}, #Function<4.74501935/4 in Flow.Materialize.build_reducer/2>}
** (exit) exited in: GenStage.close_stream(%{})
    ** (EXIT) exited in: GenStage.close_stream(%{})
        ** (EXIT) an exception was raised:
            ** (Protocol.UndefinedError) protocol Enumerable not implemented for {:cont, {:cont, %{}}} of type Tuple, Flow attempted to convert the stage accumulator into events but failed, to explicit convert your current state into events use on_trigger/2. This protocol is implemented for the following type(s): Flow, Date.Range, File.Stream, Function, GenEvent.Stream, HashDict, HashSet, IO.Stream, List, Map, MapSet, Range, Stream
                (elixir 1.10.3) lib/enum.ex:1: Enumerable.impl_for!/1
                (elixir 1.10.3) lib/enum.ex:141: Enumerable.reduce/3
                (elixir 1.10.3) lib/enum.ex:3383: Enum.reverse/1
                (elixir 1.10.3) lib/enum.ex:2984: Enum.to_list/1
                (flow 1.0.0) lib/flow/materialize.ex:642: anonymous fn/3 in Flow.Materialize.build_trigger/1
                (flow 1.0.0) lib/flow/map_reducer.ex:87: Flow.MapReducer.done_status/4
                (flow 1.0.0) lib/flow/map_reducer.ex:35: Flow.MapReducer.handle_cancel/3
                (gen_stage 1.0.0) lib/gen_stage.ex:2096: GenStage.noreply_callback/3
    (gen_stage 1.0.0) lib/gen_stage/stream.ex:160: GenStage.Stream.close_stream/1
    (elixir 1.10.3) lib/stream.ex:1415: Stream.do_resource/5
    (elixir 1.10.3) lib/stream.ex:880: Stream.do_transform/5
    (elixir 1.10.3) lib/enum.ex:605: Enum.count/1

सादर

0
Omar K 9 जुलाई 2020, 00:07

1 उत्तर

सबसे बढ़िया उत्तर

प्रोटोकॉल संख्यात्मक {:cont, {:cont, %{}}} प्रकार के लिए लागू नहीं किया गया टपल

उदाहरण के लिए:

iex(1)> t = {1, {:a, :b, :c}}
{1, {:a, :b, :c}}


iex(2)> Enum.any?(t, fn x -> x==1 end)
** (Protocol.UndefinedError) protocol Enumerable not implemented for {1, {:a, :b, :c}}
    (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) lib/enum.ex:141: Enumerable.reduce/3
    (elixir) lib/enum.ex:349: Enum.any?/2 
0
7stud 9 जुलाई 2020, 18:36