lsearch -real

49 views
Skip to first unread message

Manfred Rosenberger

unread,
Jan 25, 2023, 7:25:50 PMJan 25
to
I do not understand the option -real
% lsearch -real {0 1 2} 0.0
-1
% lsearch -real {0 1 2} 0
0
% lsearch -real {0.0 1 2} 0.00
-1
% lsearch -exact {0.0 1 2} 0.00
-1
% lsearch -exact {0.0 1 2} 0.0
0
%
------------
it does not recognize
0 in {0 1 2} as the same as 0.0
0.0 in {0.0 1 2} as the same as 0
------------
to do a exact matching I could use: lsearch -exact ..
-----------
so how shall I expect the option -real is working?
---------
Thanks for responding!
Manfred

pd

unread,
Jan 25, 2023, 11:01:31 PMJan 25
to
% lsearch -exact -real {0.0 1 2} 0.00
0

man n lsearch

heinrichmartin

unread,
Jan 26, 2023, 2:36:33 AMJan 26
to
Also note that you can search newsgroups.

Thread "lsearch -real not working as expected" is a prominent search results for "lsearch real".

To be fair, the wiki search did not help. Also, that thread is as old as COVID-19. But as you can see, the community will help out anyway ;-)

Ralf Fassel

unread,
Jan 26, 2023, 11:13:25 AMJan 26
to
* pd <p...@anon.net>
To be precise:

CONTENTS DESCRIPTION OPTIONS
These options describe how to interpret the items in the list being
searched. ***They are only meaningful when used with the -exact and
-sorted options.***

(*** emphasis by me)

-real The list elements are to be compared as floating-point values.

So you need both -real *and* -exact.

R'

Manfred Rosenberger

unread,
Jan 26, 2023, 6:26:37 PMJan 26
to
I see!
thx a lot!
Manfred
Reply all
Reply to author
Forward
0 new messages