Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'flows': 0.07; 'formed': 0.07; 'alignment': 0.09; 'definitions.': 0.09; 'length.': 0.09; 'necessary,': 0.09; 'readable': 0.09; 'restored': 0.09; 'syntax.': 0.09; 'value:': 0.09; 'result,': 0.15; 'course:': 0.16; 'disregard': 0.16; 'grasping': 0.16; 'received:209.85.161.174': 0.16; 'received:mail-gx0-f174.google.com': 0.16; 'remembered': 0.16; 'sequence.': 0.16; 'subject:programming': 0.16; '\xa0as': 0.16; 'cc:addr:python-list': 0.16; 'examples': 0.16; 'mechanism': 0.19; 'sfxlen:2': 0.19; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'implicit': 0.23; 'stops': 0.23; 'cc:2**0': 0.26; 'function': 0.27; 'skip:[ 10': 0.27; 'message-id:@mail.gmail.com': 0.29; 'assuming': 0.29; 'explicit': 0.29; 'explicitly': 0.29; 'cc:addr:python.org': 0.29; 'seem': 0.29; 'cases.': 0.30; 'rigorous': 0.30; 'rough': 0.30; 'equivalent': 0.31; 'pretty': 0.31; 'point,': 0.32; 'thanks': 0.32; 'sort': 0.33; 'there': 0.33; 'this.': 0.33; 'rules': 0.34; 'received:209.85.161': 0.34; 'identical': 0.34; 'implies': 0.34; 'here,': 0.35; 'two': 0.36; 'element': 0.37; 'push': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'some': 0.38; 'think': 0.38; 'should': 0.38; 'easier': 0.38; 'non': 0.38; 'skip:\xa0 10': 0.39; 'received:209': 0.39; 'back': 0.60; 'more': 0.61; 'achieve': 0.61; 'your': 0.61; 'special': 0.66; 'stream': 0.77; 'algebra': 0.84; 'chain:': 0.84; 'communicate,': 0.84; 'nathan': 0.84; 'streams': 0.84; 'to:addr:mail.python.org': 0.91; 'calculus': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=2ufWwAqKirTScZK5XR3GEGM8Blb545TWSULCKDhwM7A=; b=a2oSpVBoOMjXlL42nGUcqX+Isje8CqBSOLv6lCb/11mTkNzrpnnqcPGtiN9OMGjIJC ++omb4O+GRiq/nZktN65mTKREZUp6uDVKKCiHQnaM/OzYmVFQbvRf/ePT1Q58DOmAHZZ LmHLM6bd6dj8oh5RQCZFgNSWGFj4r3FU3A5rR5v+wvaZN6Airvx4SL64Bq5iDhwuvv8W T/+jvg/++IDenCA2KGxi1m7qafqefk3GW2DMqACfrxIr6NKh9Qd6V82qI65KQ0CwuhhT BJQ5lMHmmOf0wmIEQ/onuACC4eYqgdtxK4iak7LxuABYAP6uHVgeRChtyy4zmX9icek8 e1xw== MIME-Version: 1.0 In-Reply-To: <4f6c9e17$0$1383$4fafbaef@reader2.news.tin.it> References: <4f6c9e17$0$1383$4fafbaef@reader2.news.tin.it> Date: Fri, 23 Mar 2012 12:33:35 -0400 Subject: Re: Stream programming From: Nathan Rice To: Kiuhnm Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 65 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332520419 news.xs4all.nl 6905 [2001:888:2000:d::a6]:35861 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22084 > I will use "<=3D>" to mean "is equivalent to". That's not part of the DSL= . > A flow has one or more streams: > =A01 stream: > =A0 =A0[1,2,3] > =A02 streams: > =A0 =A0[1,3,5] | [2,4,6] > Two flows can be concatenated: > =A0[1,2,3] + [4,5,6] <=3D> [1,2,3,4,5,6] > =A0[0] + ([1,2] | [3,4]) + [10] <=3D> [0,1,2,10] | [0,3,4,10] > =A0([1,2] | [10,20]) + ([3,4] | [30,40]) <=3D> [1,2,3,4] | [10,20,30,40] Algebraically, your concatenation rules don't really make sense - your flows are both distributive and non distributive. You also make the implicit assumption of an order over streams in a flow, but disregard the implications of that assumption in some cases. I understand what you're trying to communicate, so I think you need to be a little more strict and explicit in your definitions. > A flow can be transformed: > =A0[1,2] - f <=3D> [f(1),f(2)] > =A0([1,2] | [3,4]) - f <=3D> [f(1,3),f(2,4)] > =A0([1,2] | [3,4]) - [f] <=3D> [f(1),f(2)] | [f(3),f(4)] > =A0([1,2] | [3,4]) - [f,g] <=3D> [f(1),f(2)] | [g(3),g(4)] > =A0[1,2] - [f,g] <=3D> [f(1),f(2)] | [g(1),g(2)] Given the examples you pose here, it is clear that you are assuming that the streams are synchronized in discrete time. Since you do not provide any mechanism for temporal alignment of streams you are also assuming every stream will have an element at every time point, the streams start at the same time and are of the same length. Is this what you want? These seem like pretty rough simplifying assumptions. > Some functions are special and almost any function can be made special: > =A0[1,2,3,4,5] - filter(isprime) <=3D> [2,3,5] > =A0[[],(1,2),[3,4,5]] - flatten <=3D> [1,2,3,4,5] > Note that 'filter' is not really necessary, thanks to 'flatten'. This implies that your transformations again produce flows. You should explicitly state this. > Flows can be named, remembered and used > =A0as a value: > =A0 =A0[1,2,3,4,5] - 'flow' + val('flow') <=3D> [1,2,3,4,5]*2 Is this a flow with two identical streams, or a flow with one long stream formed by concatenation? > =A0as a transformation chain: > =A0 =A0[1,2,3] - skipfirst - 'again' | [4,5,6] - func('again') > =A0 =A0 =A0<=3D> [2,3] | [5,6] > =A0Recursion is also possible and stops when a function is applied to an = empty > sequence. > Flows can be saved (push) and restored (pop) : > =A0[1,2,3,4] - push - by(2) - 'double' - pop | val('double') > =A0 =A0 =A0<=3D> [1,2,3,4] | [2,4,6,8] > There are easier ways to achieve the same result, of course: > =A0[1,2,3,4] - [id, by(2)] You are grasping at an algebra here, a sort of calculus of temporal observations. You need to step back and make it rigorous before you worry about issues such as a readable syntax. Nathan