X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=i8cYPKFXR0+TKCAbWiptP3uLhIqSmkcNfobbgA+LQkc=; b=S/1j4FDXc6X4Mv2scGT9vABIGjP1cSlcAxmoTk5tKLEgwtBi6lHjBmlIQ4jxaekJf1 o5CX5UHTZEfk4wS6JDEnEWjxPc8oE/tJi34fcxmSKEmy3WgbNXjtgNxeRfMO7ms/AmjJ 0gpnkkEPhaXWsN+ZO4CI/izixgJEAcyWTrfkqtEgx/QEiBqfPIqGVynvQTFdyFnVItPD fkcg1SPtOQGyNf3M20TA92sdn+7TADkSdyVlBcEqYN9VgvNKiSdkfRhScD6UouVvRrGb 4fJgLTPiWrKU+6O8+vZSRRW39LsQDRqthw3lLMssGltchFeLHxBkCcgIKUHqO8yXmBtJ ODHQ== X-Received: by 10.112.17.70 with SMTP id m6mr851504lbd.113.1442007683617; Fri, 11 Sep 2015 14:41:23 -0700 (PDT) Date: Sat, 12 Sep 2015 00:41:21 +0300 From: "Vladimir Zhbanov (vzhbanov AT gmail DOT com) [via geda-user AT delorie DOT com]" To: geda-user AT delorie DOT com Subject: Re: [geda-user] About reinventing the wheel, and how to avoid it Message-ID: <20150911214120.GB7946@localhost.localdomain> Mail-Followup-To: geda-user AT delorie DOT com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Reply-To: geda-user AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: geda-user AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Fri, Sep 11, 2015 at 04:06:36PM +0200, Roland Lutz wrote: ... > Imagine the following SQL query: > > DELETE FROM objects WHERE radius = 0.; > > Using Xorn as an example, you could either iterate over all objects, looking > for circles and arcs wth a matching radius, and delete these objects: > > xorn_object_t *objects; > size_t count; > unsigned int i; > > xorn_get_objects(rev, &objects, &count); > > for (i = 0; i < count; i++) { > xorn_obtype_t type = xorn_get_object_type(rev, objects[i]); > > if (type == xornsch_obtype_circle && > xornsch_get_circle_data(rev, objects[i])->radius == 0.) > xorn_delete_object(rev, objects[i]); > > if (type == xornsch_obtype_arc && > xornsch_get_arc_data(rev, objects[i])->radius == 0.) > xorn_delete_object(rev, objects[i]); > } > > free(objects); And that's an impenetrable code for the same in Guile: (use-modules (geda page)) ; Checks if the OBJECT is a circle or an arc with zero radius (define (zero-radius-object? object) (or (and (circle? object) (= (circle-radius object) 0)) (and (arc? object) (= (arc-radius object) 0)))) (apply page-remove! (active-page) (filter zero-radius-object? (page-contents (active-page)))) Just about reinvention of the wheel. :-/ Cheers, Vladimir