Paste number 51973: macro; need help here

Index of paste annotations: 2 | 1

Paste number 51973: macro; need help here
Pasted by: hannes
When:1 year, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+143P
Channel:#dylan
Paste contents:
Raw Source | XML | Display As
define macro graph
 { graph ( ?connections:* ) }
    => { begin
           let g = make(<graph>);
           add-edges(g, list(?connections));
           g;
         end }

    connections:
    { } => { }
    { ?snode:name -> ?tnode:name ; ... } =>
      { ?"snode", ?"tnode" , ... }
    { ?snode:name -> ?tnode:name -> ?unode:name ; ... } =>
      { ?"snode", ?"tnode", ?"tnode", ?"unode", ... }
    { ?snode:name -> ?tnode:name -> ?unode:name -> ?vnode:name ; ... } =>
      { ?"snode", ?"tnode", ?"tnode", ?"unode", ?"unode", ?"vnode", ... }
end;

I would like to have only two rules in the connections auxiliary macro

Annotations for this paste:

Annotation number 2: How about this?
Pasted by: |Agent
When:1 year, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+143P#2
Paste contents:
Raw Source | Display As
define macro graph
 { graph ( ?edges:* ) }
    => { begin
           let g = make(<graph>);
           ?edges;
           add-edges(g, list(?connections));
           g;
         end }

    edges:
    { } => { }
    { ?connections ; ... } =>
      { add-edges(g, list(?connections)) }

    connections:
    { ?node:name } => { ?"node" }
    { ?node:name -> ... } { ?"node", ... }
end;

Annotation number 1: macro usage
Pasted by: hannes
When:1 year, 6 months ago
Share:Tweet this! | http://paste.lisp.org/+143P#1
Paste contents:
Raw Source | Display As
  let new-graph = graph ( foo -> bar -> boo; bluub -> foo );

Colorize as:
Show Line Numbers
Index of paste annotations: 2 | 1

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.