Easy as { 1 2 3 }? (when { 1 2 3 } ≠ { 1 2 3 })
07-15-2018, 02:38 PM
Post: #7
 Dave Britten Senior Member Posts: 2,074 Joined: Dec 2013
RE: Easy as { 1 2 3 }?
Here's a fairly succinct 50g program that uses DOLIST and STREAM to compare elements (and has special cases to handle empty or single-element lists).

Code:
 \<<   DUP2 SIZE SWAP SIZE OVER ==   \<<     0. ==     \<< DROP2 1. \>>     \<< 2. \<< == \>> DOLIST       DUP SIZE 1. ==       \<< LIST\-> DROP \>>       \<< \<< AND \>> STREAM \>>       IFTE     \>>     IFTE   \>>   \<< DROP2 DROP 0. \>>   IFTE \>>

You could change the "\<< == \>>" DOLIST argument to do type checking and recursion if you want it to work on nested lists.

Corrections/improvements welcome, as always.
 « Next Oldest | Next Newest »

 Messages In This Thread Easy as { 1 2 3 }? (when { 1 2 3 } ≠ { 1 2 3 }) - DavidM - 07-14-2018, 10:52 PM RE: Easy as { 1 2 3 }? - Joe Horn - 07-15-2018, 12:52 AM RE: Easy as { 1 2 3 }? - DavidM - 07-15-2018, 01:41 AM RE: Easy as { 1 2 3 }? - Joe Horn - 07-15-2018, 04:12 AM RE: Easy as { 1 2 3 }? - DavidM - 07-15-2018, 04:52 AM RE: Easy as { 1 2 3 }? - Claudio L. - 07-15-2018, 05:54 PM RE: Easy as { 1 2 3 }? - DavidM - 07-15-2018, 06:07 PM RE: Easy as { 1 2 3 }? - Claudio L. - 07-16-2018, 04:25 AM RE: Easy as { 1 2 3 }? - DavidM - 07-17-2018, 03:05 AM RE: Easy as { 1 2 3 }? - rprosperi - 07-17-2018, 03:26 AM RE: Easy as { 1 2 3 }? - DavidM - 07-17-2018, 03:31 AM RE: Easy as { 1 2 3 }? - Massimo Gnerucci - 07-17-2018, 06:33 AM RE: Easy as { 1 2 3 }? - John Keith - 07-17-2018, 12:32 PM RE: Easy as { 1 2 3 }? - Massimo Gnerucci - 07-17-2018, 02:11 PM RE: Easy as { 1 2 3 }? - John Keith - 07-17-2018, 08:49 PM RE: Easy as { 1 2 3 }? - John Keith - 07-15-2018, 01:01 PM RE: Easy as { 1 2 3 }? - Dave Britten - 07-15-2018 02:38 PM RE: Easy as { 1 2 3 }? - DavidM - 07-15-2018, 05:21 PM RE: Easy as { 1 2 3 }? - Eddie W. Shore - 07-17-2018, 12:43 PM RE: Easy as { 1 2 3 }? - rprosperi - 07-17-2018, 01:06 PM RE: Easy as { 1 2 3 }? - DavidM - 07-17-2018, 01:41 PM RE: Easy as { 1 2 3 }? - John Keith - 07-17-2018, 08:42 PM RE: Easy as { 1 2 3 }? - ttw - 07-17-2018, 04:00 PM RE: Easy as { 1 2 3 }? - BartDB - 07-17-2018, 04:51 PM RE: Easy as { 1 2 3 }? - pier4r - 08-07-2018, 04:07 PM RE: Easy as { 1 2 3 }? (when { 1 2 3 } ≠ { 1 2 3 }) - DavidM - 08-07-2018, 11:40 PM RE: Easy as { 1 2 3 }? (when { 1 2 3 } ≠ { 1 2 3 }) - pier4r - 08-08-2018, 07:06 AM

User(s) browsing this thread: 1 Guest(s)