(*---------------------------------------------------------------------------
Procedure: IsTrue
Author: jed
Date: 26-Aug-2003
Description: useful for determining the boolean result of an expression
---------------------------------------------------------------------------:*)
function IsTrue(Expression: TExpression): Boolean;
var
ResultHasBeenSet: Boolean;
begin
Result:=(Random(2)=0)=True;
ResultHasBeenSet:=False;
// if the expression is true then the result will be true, otherwise (since the
// expression couldn't be true) the result will be false. There are no other
// mathematical possibilities
begin
if (Expression=True) then
begin
Result:=True;
ResultHasBeenSet:=True;
end;
if (Expression=False) then
begin
Result:=False;
ResultHasBeenSet:=True;
end;
end;
// need to set the result if it hasn't been set yet, we'll randomly decide true or false
// because there should be no bias.
if IsTrue(ResultHasBeenSet)=IsTrue(0=1)
then Result:=((Random(2)=Random(2))=True)
else Result:=(Result=True);
// P.S.
// This function could also be adapted to tell you if some expression is false
// by prefixing the expression (or the result) with the 'not' operator. You can
// find out more about the 'not' operator in the online help.
end; http://thedailywtf.com/forums/43457/ShowPost.aspx
Ответ на:
комментарий
от Deleted

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от Gharik

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от anonymous
Ответ на:
комментарий
от lester_dev


Ответ на:
комментарий
от anonymous
Ответ на:
комментарий
от hatefu1_dead
Ответ на:
комментарий
от anonymous
Ответ на:
комментарий
от hatefu1_dead
Ответ на:
комментарий
от hatefu1_dead
Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от Gharik
Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от anonymous
Ответ на:
комментарий
от anonymous
Ответ на:
комментарий
от Gharik
Ответ на:
комментарий
от hatefu1_dead
Ответ на:
комментарий
от anonymous

Ответ на:
комментарий
от mutronix
Ответ на:
комментарий
от record
Ответ на:
комментарий
от Xellos
Ответ на:
комментарий
от anonymous
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.
Похожие темы
- Форум Правильно портировать Pascal код (2018)
- Форум Pascal системы исчисления (2022)
- Форум PostgreSQL: UPDATE из DELETE-триггера в обход UPDATE-триггера (2016)
- Форум Как ускорить опрос файлов? (2016)
- Форум [ubuntu 11.10][awesome]не меняются обои (2011)
- Форум Free Pascal программа в терминале (2023)
- Форум [Паскалъ] Need Help (2011)
- Форум Оператор read в Pascal отказывается читать пробельные символы (2022)
- Форум [Kernel Panic] Viruchaite! (2011)
- Форум Не отображается индикатор раскладки клавиатуры (Archlinux, Awesome 3.5.5, Kbdd) (2014)