Paste number 67460: Guardedness condition

Index of paste annotations: 1

Paste number 67460: Guardedness condition
Pasted by: vas
When:1 year, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+1G1W
Channel:None
Paste contents:
Raw Source | XML | Display As
Set Implicit Arguments.
Implicit Arguments LNil [A].

CoFixpoint append (A:Set) (l1 l2 : LList A) : LList A :=
  match l1 with
  | LNil => l2
  | LCons x xs => LCons x (append xs l2)
  end.

CoFixpoint cycle (A:Set) (input : LList A) : LList A :=
  match input with
  | LNil => LNil
  | LCons x xs => LCons x (append xs (cycle input))  (* "unguarded recursive call" *)
  end.

Annotations for this paste:

Annotation number 1: how to do it.
Pasted by: roconnor
When:1 year, 4 months ago
Share:Tweet this! | http://paste.lisp.org/+1G1W/1
Paste contents:
Raw Source | Display As
Section Foo.

Variable A:Set.
Variable l2:LList A.

CoFixpoint append0 l1 : LList A :=
  match l1 with
  | LNil => l2
  | LCons x xs => LCons x (append0 xs)
  end.

End Foo.

Definition append (A:Set) (l1 l2:LList A) := append0 l2 l1.

CoFixpoint cycle (A:Set) (input : LList A) : LList A :=
  match input with
  | LNil => LNil
  | LCons x xs => LCons x (append xs (cycle input))  (* "unguarded recursive call" *)
  end.

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

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