1. Список говнокодов пользователя CHayT

    Всего: 87

  2. Куча / Говнокод #27708

    +2

    1. 001
    2. 002
    3. 003
    4. 004
    5. 005
    6. 006
    7. 007
    8. 008
    9. 009
    10. 010
    11. 011
    12. 012
    13. 013
    14. 014
    15. 015
    16. 016
    17. 017
    18. 018
    19. 019
    20. 020
    21. 021
    22. 022
    23. 023
    24. 024
    25. 025
    26. 026
    27. 027
    28. 028
    29. 029
    30. 030
    31. 031
    32. 032
    33. 033
    34. 034
    35. 035
    36. 036
    37. 037
    38. 038
    39. 039
    40. 040
    41. 041
    42. 042
    43. 043
    44. 044
    45. 045
    46. 046
    47. 047
    48. 048
    49. 049
    50. 050
    51. 051
    52. 052
    53. 053
    54. 054
    55. 055
    56. 056
    57. 057
    58. 058
    59. 059
    60. 060
    61. 061
    62. 062
    63. 063
    64. 064
    65. 065
    66. 066
    67. 067
    68. 068
    69. 069
    70. 070
    71. 071
    72. 072
    73. 073
    74. 074
    75. 075
    76. 076
    77. 077
    78. 078
    79. 079
    80. 080
    81. 081
    82. 082
    83. 083
    84. 084
    85. 085
    86. 086
    87. 087
    88. 088
    89. 089
    90. 090
    91. 091
    92. 092
    93. 093
    94. 094
    95. 095
    96. 096
    97. 097
    98. 098
    99. 099
    100. 100
    % Totoro sitting in the snow
    % By Noa Hoffmann and Pascal Günthner, 21.12.2020
    \documentclass[tikz,11pt]{{standalone}}
    \usepackage{calligra}
    \usepackage[T1]{fontenc}
    \usetikzlibrary{%
      shapes, shadows, patterns, calc,
      decorations.shapes,
      decorations.fractals,
      decorations.markings,
      decorations.pathmorphing
    }
    
    \colorlet{bodycolor}{black!35!gray!60!brown!98!green}
    \colorlet{bellycolor}{yellow!70!white!92!green}
    
    \tikzset{
       furspot/.pic = {
        \path [draw = black, thick, fill] (0,0)    
        .. controls +(0.3,0)        and  +(0.25,-0.05)   ..  ++(0.35,-.45)
        .. controls +(-0.45,0.25)   and  +(0.1,0)        ..  ++(-0.85,-0.05)
        .. controls +(-0.3,0.1)     and  +(-0.4, 0)      ..  cycle;
       },
       claw/.pic = {
        \path [fill = bodycolor!70, draw] (0,0) arc (0:45:0.2 and 0.8)
                                               arc (135:180:0.2 and 0.8)
        arc (180:360:0.059) -- cycle;
       },
       whiskers/.pic = {
        \path [fill = bodycolor!70,draw] (0,0) arc (0:45:0.05 and 2.3)
                                            arc (135:180:0.3 and 2.3)
        to[out=-90,in=-90] cycle;
       },
       snowflake/.pic = {
       \fill [decoration = Koch snowflake, white] decorate{ decorate{
              decorate{ (-0.5,-0.3) -- ++(60:1) -- ++(-60:1) -- cycle }}};
       \foreach \i in {30, 90, 150, 210, 270, 330} {
            \draw[blue!50!white,very thin] (0,0) -- +(\i:0.3);
            }
        \draw[decoration = Koch snowflake, blue!50!white, very thin]
              decorate{($(0,0)+(60:0.2)$) -- ($(0,0)+(300:0.2)$) --
                       ($(0,0)+(180:0.2)$) -- cycle};
       }
    }
    \tikzset{
      snow/.style   = {decoration = {random steps, segment length = 2mm,
                       amplitude = 0.4mm}, decorate},
      plush/.style  = {decoration = {random steps, segment length = 1mm,
                       amplitude = 0.5mm},decorate}
    }
    
    \begin{document}
    \begin{tikzpicture}[color = bodycolor, draw = black, thick]
    
    %---------------------background and tail----------------------
    % blue sky
    \fill[blue!30!white] (-8cm,-11cm) rectangle (8cm,10cm);
    % random snowflakes
    \foreach \i in {0.1,0.11,...,1}{
      \pic [scale = \i, opacity = 0.9] at (rand*7.5, rnd*18-10.5) {snowflake};}
    % more tiny snowflakes
    %\foreach \i in {0.1,0.11,...,0.5}{
      %\pic [scale = \i, opacity = 0.9] at (rand*7.5, rnd*18-10.5) {snowflake};}
    % cloud with merry christmas
    \node [cloud,aspect = 6.5, cloud puff arc = 120, cloud puffs = 12.9, fill = white,
           color = white] at (0,7) {\Huge M \hspace{9.8cm}.};
    \node [color = red] at (0,7) {\fontsize{50}{80}
                                  \textbf{Merry Christmas \quad }};
    % tail
    \path [draw, fill, rotate = 50] (-4,-7.5) circle (1.5 and 2.2);
    % snowhill
    \fill [draw, gray!6, snow] (-8,-11) to[in=200, out=0] (-3,-7.5) to (3,-7.5)
          to[out=-20, in=180] (8,-11);
    
    %--------------------body-----------------------------------------
    % right ear
    \path [fill, draw] (0.6,2.3)+(-45:1) arc (-60:35:1 and 1.5) 
                       arc (115:210:1 and 1.5);
    % left ear
    \path [fill, draw] (-0.6,2.3)+(-135:1) arc (-120:-215:1 and 1.5)
                       arc (65:-30:1 and 1.5);
    % head
    \path [draw, fill] ($(0,0)+(170:2.5 and 2)$) arc (170:10:2.5 and 2)
                       arc(35:-20: 3 and 2)
            -- ($(0,-0.8)+(200:3 and 2)$) arc (200:145:3 and 2) -- cycle;
    % body
    \path[fill] ($(0,-4)+(200:4 and 4.5)$) arc (200:-20:4 and 4.5);
    
    %----------------------face----------------------------------------
    % left eye
    \path [draw, fill = white] (-1.4,0.7) circle (0.45 and 0.4);
    \fill [black] (-1.2,0.7) circle (0.16);
    \fill [white] (-1.24,0.74) circle (0.03);
    % right eye
    \path [draw, fill = white, thick] (1.4,0.7) circle (0.4);
    \fill [black] (1.25,0.7) circle (0.16);
    \fill [white] (1.20,0.74) circle (0.03);
    % nose
    \path [draw] (0.35, 0.7) .. controls (0.2,0.8) and (-0.2, 0.8)
                             .. (-0.35, 0.7);

    Какое аниме ))) https://texample.net/tikz/examples/totoro/

    CHayT, 08 Октября 2021

    Комментарии (17)
  3. Куча / Говнокод #27640

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    -module(pqueue).
    
    -export([ in/3
            , out/1
            , new/0
            , close/1
            ]).
    
    -type prio() :: non_neg_integer().
    
    -record(priority_queue,
            { tab :: ets:tid()
            }).
    
    -define(size, {size, size}).
    -define(seqno(PRIO), {seqno, PRIO}).
    
    -opaque t() :: #priority_queue{}.
    
    -export_type([ prio/0
                 , t/0
                 ]).
    
    -spec new() -> t().
    new() ->
      Tab = ets:new(pqueue_tab, [ordered_set]),
      ets:insert(Tab, {?size, 0}),
      #priority_queue{tab = Tab}.
    
    -spec close(t()) -> ok.
    close(#priority_queue{tab = Tab}) ->
      true = ets:delete(Tab),
      ok.
    
    -spec in(term(), prio(), t()) -> ok.
    in(Val, Prio, #priority_queue{tab = Tab}) when Prio >= 0 ->
      Key = {get_next_seqno(Tab, Prio), Prio},
      true = ets:insert_new(Tab, {Key, Val}),
      ets:update_counter(Tab, ?size, {2, 1}, {?size, 0}),
      ok.
    
    -spec out(t()) -> {value, term()} | empty.
    out(#priority_queue{tab = Tab}) ->
      case ets:first(Tab) of
        Key = {SeqNo, _Prio} when is_integer(SeqNo) ->
          Val = ets:lookup_element(Tab, Key, 2),
          ets:update_counter(Tab, ?size, {2, -1}),
          ets:delete(Tab, Key),
          {value, Val};
        _ ->
          empty
      end.
    
    %% This function generates keys that go in sequence for each
    %% individual priority level, but interleave for different priority
    %% levels. Keys with lower priority are more sparse, so they are
    %% consumed less often in the total sequence
    get_next_seqno(Tab, Prio) ->
      Delta = Prio + 1,
      Key = ?seqno(Prio),
      ets:update_counter(Tab, Key, {2, Delta}, {Key, 0}).

    Творение безумца или гения.

    CHayT, 02 Сентября 2021

    Комментарии (3)
  4. bash / Говнокод #27560

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    #!/bin/bash
    set -euo pipefail
    
    host() {
        echo "n${1}.local"
    }
    
    node() {
        echo "erl@$(host $1)"
    }
    
    build() {
        [ "${1}" -eq "1" ] && echo "build: ."
    }
    
    container() {
        cat <<EOF
      worker${1}:
        $(build $1)
        image: worker
        hostname: $(host $1)
        networks:
          backplane:
            aliases:
              - $(host $1)
    
        environment:
        - "NODE_NAME=$(node $1)"
        - ... прочая питушня
    EOF
    }
    
    main() {
        cat <<EOF
    version: '3.3'
    
    networks:
      backplane:
    
    services:
    $(node 1)
    
    $(node 2)
    
    ...
    EOF
    }
    
    main > docker-compose.yml
    docker-compose $@

    Как тебе такое, Helm?

    CHayT, 13 Августа 2021

    Комментарии (35)
  5. Куча / Говнокод #27547

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    Ltac destruct_mint_ H := 
       match type of H with
          (MInt_ _ ?z ?t) =>
          lazymatch goal with
            |- ?GOAL =>
            refine (match H in (MInt_ _ z0 t0) return (z = z0 -> t = t0 -> GOAL) with
                    | mint_nil    _  =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons   _ te rest l      r   t H =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons_l _ te rest l r z t Hz H  =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    | mint_cons_r _ te te' rest l r z t Hz Hcomm H =>
                      fun Heq_z Heq_tt_ =>
                        ltac:(destruct_mint_common Heq_tt_ Heq_z H)
                    end (eq_refl z) (eq_refl t))
          end
        end.

    Наебавшись с inversion в механизированным доказательстве, закрыл я очи.

    CHayT, 04 Августа 2021

    Комментарии (23)
  6. Куча / Говнокод #27522

    +2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    ...
    
           fun([N1, _N2], Trace) ->
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Adding table to a shard", shard := _Shard, live_change := true}
                                       , #{?snk_kind := "Shard schema change"}
                                       , ?of_node(N1, Trace)
                                       )),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Shard schema change", shard := _Shard}
                                       , #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , ?of_node(N1, Trace)
                                       )),
                   %% Schema change must cause restart of the replica process and bootstrap:
                   {_, Rest} = ?split_trace_at(#{?snk_kind := "Shard schema change"}, Trace),
                   ?assert(
                      ?strict_causality( #{?snk_kind := "Restarting shard server", shard := _Shard}
                                       , #{?snk_kind := state_change, to := bootstrap}
                                       , Rest
                                       ))
           end).

    Немного galaxy-brain тестов

    CHayT, 17 Июля 2021

    Комментарии (19)
  7. Куча / Говнокод #27475

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    dirty_boostrap_test() ->
        SourceTab = ets:new(source, [public, named_table]),
        ReplicaTab = ets:new(replica, [public, named_table]),
        %% Insert some initial data:
        ets:insert(source, {1, 1}),
        ets:insert(source, {2, 2}),
        ets:insert(source, {3, 3}),
        try
            register(testcase, self()),
            Replica = spawn_link(fun replica/0),
            register(replica, Replica),
            %% "importer" process emulates mnesia_tm:
            spawn_link(fun importer/0),
            %% "bootstrapper" process emulates bootstrapper server:
            spawn_link(fun bootstrapper/0),
            receive
                done ->
                    SrcData = lists:sort(ets:tab2list(source)),
                    RcvData = lists:sort(ets:tab2list(replica)),
                    ?assertEqual(SrcData, RcvData)
            end
        after
            ets:delete(SourceTab),
            ets:delete(ReplicaTab)
        end.
    
    importer() ->
        Ops = [ {write, 3, 3}
              , {write, 4, 4}
              , {write, 4, 5}
              , {delete, 2}
              ],
        lists:map(fun(OP) ->
                          import_op(source, OP),
                          %% Imitate mnesia event (note: here we send it
                          %% directly to the replica process bypassing
                          %% the agent):
                          replica ! {tlog, OP}
                  end,
                  Ops),
        replica ! last_trans.
    
    replica() ->
        receive
            {bootstrap, K, V} ->
                ets:insert(replica, {K, V}),
                replica();
            bootstrap_done ->
                replay()
        end.
    
    replay() ->
        receive
            {tlog, Op} ->
                import_op(replica, Op),
                replay();
            last_trans ->
                testcase ! done
        end.
    
    import_op(Tab, {write, K, V}) ->
        ets:insert(Tab, {K, V});
    import_op(Tab, {delete, K}) ->
        ets:delete(Tab, K).
    
    bootstrapper() ->
        {Keys, _} = lists:unzip(ets:tab2list(source)),
        [replica ! {bootstrap, K, V} || K <- Keys, {_, V} <- ets:lookup(source, K)],
        replica ! bootstrap_done.

    Follow-up к треду про то, как делать снепшоты.

    CHayT, 20 Июня 2021

    Комментарии (69)
  8. Куча / Говнокод #27464

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    85. 85
    86. 86
    87. 87
    88. 88
    89. 89
    90. 90
    91. 91
    92. 92
    93. 93
    insert(Alias, Tab, Val) ->
        ok.
    
    delete(_Alias, _Tab, _Key) ->
        ok.
    
    add_aliases(_) ->
        ok.
    
    remove_aliases(_) ->
        ok.
    
    check_definition(_Alias, _Tab, _Nodes, _Properties) ->
        ok.
    
    close_table(_Alias, _Tab) ->
        ok.
    
    create_table(_Alias, _Tab, _Properties) ->
        ok.
    
    delete_table(_Alias, _Tab) ->
        ok.
    
    first(_Alias, _Tab) ->
        '$end_of_table'.
    
    fixtable(_Alias, _Tab, _Bool) ->
        ok.
    
    last(_Alias, _Tab) ->
        '$end_of_table'.
    
    index_is_consistent(_Alias, _IxTag, _Bool) ->
        ok.
    
    init_backend() ->
        ok.
    
    info(_Alias, Tab, memory) ->
        0;
    info(Alias, Tab, size) ->
        0;
    info(_Alias, _Info, _Item) ->
        nobody_here_but_us_chicken.
    
    lookup(_Alias, _Tab, _Key) ->
        [].
    
    is_index_consistent(_Alias, _IxTag) ->
        true.
    
    load_table(_Alias, _Tab, _Reason, _CsList) ->
        ok.
    
    match_delete(_Alias, _Tab, _Pattern) ->
        ok.
    
    next(_Alias, _Tab, _Key) ->
        '$end_of_table'.
    
    prev(_Alias, _Tab, _Key) ->
        '$end_of_table'.
    
    real_suffixes() ->
        [].
    
    repair_continuation(Continuation, _MatchSpec) ->
        Continuation.
    
    select(_Continuation) ->
        '$end_of_table'.
    
    select(_Alias, _Tab, _Pattern) ->
        '$end_of_table'.
    
    select(_Alias, _Tab, _Pattern, _Limit) ->
        '$end_of_table'.
    
    
    semantics(_Alias, storage) -> ram_copies;
    semantics(_Alias, types  ) -> [set, ordered_set, bag];
    semantics(_Alias, index_types) -> [];
    semantics(_Alias, _) -> undefined.
    
    slot(_Alias, _Tab, _Pos) ->
        '$end_of_table'.
    
    sync_close_table(_Alias, _Tab) ->
        ok.
    
    tmp_suffixes() ->
        [].

    If /dev/null is fast in web scale I will use it. Is it web scale? Does /dev/null support sharding?

    CHayT, 09 Июня 2021

    Комментарии (127)
  9. Куча / Говнокод #27400

    +1

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    %% Generates a Normal-distributed random variable using Box-Muller method
    %% from: https://github.com/basho/basho_stats/blob/develop/src/basho_stats_rv.erl
    -spec rnd_normal(integer(), integer()) -> non_neg_integer().
    rnd_normal(Mean, Sigma) ->
      Rv1 = random:uniform(),
      Rv2 = random:uniform(),
      Rho = math:sqrt(-2 * math:log(1-Rv2)),
      abs(trunc(Rho * math:cos(2 * math:pi() * Rv1) * Sigma + Mean)).

    Это норма.

    CHayT, 07 Мая 2021

    Комментарии (21)
  10. Куча / Говнокод #27377

    +1

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    %% This function is needed as a hack to guide dialyzer into inferring
    %% the correct types.
    -spec id(A) -> A.
    id(A) ->
      A.
    
    %% Где-то в header'е....
    
    -define(deftarget(RECIPE), {RECIPE, fun my_module:id/1}).
    
    %% A horrible, horrible hack to make Dialyzer infer right type of the promise return value
    -define(want(TARGET),
            (fun() ->
                 case TARGET of
                   {_, ___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer} ->
                     ___IAmSorryYouHaveToSeeThisWorkaroundForDialyzer(my_module:want(TARGET))
                 end
             end)()).

    Пути статический типизации в Erlang неисповедимы.

    CHayT, 26 Апреля 2021

    Комментарии (3)
  11. Куча / Говнокод #27372

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    -export([parse_transform/2, abstract/2]).
    
    parse_transform(Forms, _Options) ->
      normal(Forms).
    
    normal({call, _Line, {atom, _, '$$'}, [Outer]}) ->
      case Outer of
        {'fun', _, {clauses, Quoted}} ->
          %% Remove outer `fun' and only leave its clauses:
          ok;
        Quoted ->
          %% A plain term has been quoted, leave it as is:
          ok
      end,
      Result = abstract(Quoted),
      %% io:format("Quoted block ~p~n", [Result]),
      Result;
    normal(L) when is_list(L) ->
      lists:map(fun normal/1, L);
    normal(T) when is_tuple(T) ->
      list_to_tuple(lists:map(fun normal/1, tuple_to_list(T)));
    normal(T) ->
      T.
    
    -define(line, 0).
    
    %% @doc Create AST of the AST
    abstract({call, _Line, {atom, _, '$'}, [Splice]}) ->
      normal(Splice);
    abstract(Orig = {var, Line, VarName}) ->
      case lists:suffix("__AST", atom_to_list(VarName)) of
        true ->
          Orig;
        false ->
          {tuple, ?line, [ {atom, ?line, var}
                         , {integer, ?line, Line}
                         , {atom, ?line, VarName}
                         ]}
      end;
    abstract(T) when is_tuple(T) ->
      {tuple, ?line, lists:map(fun abstract/1, tuple_to_list(T))};
    abstract([]) ->
      {nil, ?line};
    abstract([Hd|Tail]) ->
      {cons, ?line, abstract(Hd), abstract(Tail)};
    abstract(A) when is_atom(A) ->
      {atom, ?line, A};
    abstract(I) when is_integer(I) ->
      {integer, ?line, I}.

    Мета-метушня, убогое подобие лисповского квотирования.

    CHayT, 23 Апреля 2021

    Комментарии (7)