micro update on programming whith infinite data structures

From: Sebastian Hanowski <sebastian_hanowski_at_gmx.de>
Date: Fri, 19 Aug 2016 08:24:25 +0200



 I just realized that I could have spared (you) (all) my fussing about lazy
equality constraints and projections in function patterns let alone complete
detours while attempting to give negative definitions of infinite data
structures.


I have no clue why it took so long until I found out that Curry let's me write


(^) f = g where g (f x) = x


infixr 0 &=

xs &= ys | head xs =:= head ys
         & head ys =:= head zs = zs

            where
            zs = tail^ (tail xs &= tail ys)


fib = head^ 1
      &= (head . tail)^ 1
      &= (tail . tail)^ (zipWith (+) fib (tail fib))


Please notice how declarative this is. Ordering of sub-expressions is insignificant


fib = (tail . tail)^ (zipWith (+) fib (tail fib))
      &= (head . tail)^ 1
      &= head^ 1


for example would do as well.


Cheers,
Sebastian
_______________________________________________
curry mailing list
curry_at_lists.RWTH-Aachen.DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/curry

Received on Fri Aug 19 2016 - 16:56:22 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 16 2019 - 07:15:09 CEST