From 24ad14399c0ef5d7fa27e18dd0c6279099da1d78 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Wed, 4 Dec 2013 09:50:27 +0100 Subject: harmonize equality testing and List CONTAINS testing --- lists.js | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'lists.js') diff --git a/lists.js b/lists.js index 2bbcd0b..60cd7e3 100644 --- a/lists.js +++ b/lists.js @@ -61,7 +61,7 @@ PushButtonMorph, SyntaxElementMorph, Color, Point, WatcherMorph, StringMorph, SpriteMorph, ScrollFrameMorph, CellMorph, ArrowMorph, MenuMorph, snapEquals, Morph, isNil, localize, MorphicPreferences*/ -modules.lists = '2013-October-08'; +modules.lists = '2013-December-04'; var List; var ListWatcherMorph; @@ -209,30 +209,18 @@ List.prototype.at = function (index) { }; List.prototype.contains = function (element) { - var num = parseFloat(element); if (this.isLinked) { - if (this.first === element) { + if (snapEquals(this.first, element)) { return true; } - if (!isNaN(num)) { - if (parseFloat(this.first) === num) { - return true; - } - } if (this.rest instanceof List) { return this.rest.contains(element); } - return false; } // in case I'm arrayed - if (contains(this.contents, element)) { - return true; - } - if (!isNaN(num)) { - return (contains(this.contents, num)) - || contains(this.contents, num.toString()); - } - return false; + return this.contents.some(function (any) { + return snapEquals(any, element); + }); }; // List conversion: -- cgit v1.3.1