| Deutsch English Français Italiano |
|
<LISP-20240402091729@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.unix.shell,comp.unix.programmer,comp.lang.misc
Subject: Re: Command Languages Versus Programming Languages
Date: 2 Apr 2024 08:18:48 GMT
Organization: Stefan Ram
Lines: 44
Expires: 1 Feb 2025 11:59:58 GMT
Message-ID: <LISP-20240402091729@ram.dialup.fu-berlin.de>
References: <uu54la$3su5b$6@dont-email.me> <uu636l$7haj$1@dont-email.me> <20240329084454.0000090f@gmail.com> <uu6om5$cmv8$1@dont-email.me> <20240329101248.556@kylheku.com> <uu6t9h$dq4d$1@dont-email.me> <20240329104716.777@kylheku.com> <uu8p02$uebm$1@dont-email.me> <20240330112105.553@kylheku.com> <uudrfg$2cskm$1@dont-email.me> <87r0fp8lab.fsf@tudado.org> <uuehdj$2hshe$1@dont-email.me> <87wmpg7gpg.fsf@tudado.org> <LISP-20240402085115@ram.dialup.fu-berlin.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de NnyKtcFmzMPAmO+9KYLgEge8Db2c0QlDpOw6OYgzamFlyA
Cancel-Lock: sha1:1yQZpBDHTLAPG6f7E+bReusZkVE= sha256:nOZUEGsmBlrY6vN5DMrm5U12rWcFdcpTW/uDUQOvUdY=
X-Copyright: (C) Copyright 2024 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Bytes: 2807
ram@zedat.fu-berlin.de (Stefan Ram) wrote or quoted:
>( SETQ DIFF
> ( LAMBDA( X )
> ( COND
> ( ( ATOMP X )
> ( COND
> ( ( = X 'X )
> 1 )
> ( T
> 0 )))
> ( T
> ( COND
> ( ( =( CAR X )'SUM )
> ( LIST 'SUM( DIFF( CADR X ))( DIFF( CADDR X )))))))))
In Python:
def diff( x ):
return 1 if x == 'x' else 0 if type( x )is str
else[ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]
if x[ 0 ]== 'sum' else None
. An attempt at indentation:
def diff( x ):
return \
1 if x == 'x' else 0 \
if type( x )is str else \
[ 'sum', diff( x[ 1 ]), diff( x[ 2 ])] \
if x[ 0 ]== 'sum' else None
. In a multiple-returns style:
def diff( x ):
if type( x )is str:
if x == 'x':
return 1
else:
return 0
else:
if x[ 0 ]== 'sum':
return [ 'sum', diff( x[ 1 ]), diff( x[ 2 ])]
.