Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Data Comparison Analysis

Name: Anonymous 2007-11-02 17:34

I have an to do a project that counts the number of comparisons made when searching an array of 1000 elements called list. One for binary search method and a hybrid method of searching. But that is beside the point. For simplicity and neatness I would like to contain everything into one method call. Maybe BinarySearch(list, target) and HybridSearch(list,target). The problem comes when I have to return both the number of comparisons made and the index of the target. I am sure there some ultra easy way to do this that I am not seeing.

Anyone?

Name: Anonymous 2007-11-02 21:21

>>11
Don't you mean that returing an array of generic objects is a syntactically obfuscated version of returning multiple values? I mean, it's not like there's any intrinsic array functions in a CPU. Arrays are a language defined feature, and unless a language is using its array mechanism to return multiple values, it's incorrect to say that it's just syntactic sugar for returning an array. In Common Lisp, I don't believe most implementations even use an array for this (I don't see any bounds check in the disassembly).

And regardless, the programmers point of view is all we're concerned about here. If there's no way to break the abstraction, then for all intents and purposes the underlying mechanism is moot, and may vary wildly between implementations. In Common Lisp, returning multiple values and making use of those bears absolutely no similarity to working with arrays. It's not syntactic sugar for it.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List