用Erlang实现二分查找算法
摘要:
算法实现如下 1 -module(bisearch). 2 -export([start/2]). 3 4 start(Value,List) -> 5 Len = length(List), 6 FirstValue = lists:nth(1, List), 7 LastValue = lists:nth(Len, List), 8 if FirstValue =:= Value orelse LastValue =:= Value -> 9 io:format("found ~w~n", [Value]); % 查找值在列表的首... 阅读全文
posted @ 2012-12-13 16:29 应无所住而生其心 阅读(536) 评论(0) 推荐(0) 编辑