������Ǥ�Ĵ�٤Ƥߤ���

�ɲä�Ĵ�٤��Τ�

  • NaN��Inf��� - ������ȿ�����
  • �֥����ͥ�å��פʿ�����

JavaScript

Perl�Ȱʳ��Ȼ��Ƥ��롣

  • NaN��NaN��Inf��Infinity�Ȥ���̾���Ȥ߹���
  • �����ͥ�å��ʿ���true������false
#!/usr/bin/js

tell_me_the_truth = function(s){
    var p;
    eval('p = ' + s);
    if (p){
        print('\'' + s + '\' (' + p + ')' + ' is TRUE.');
    }
    else{
        print('\'' + s + '\' (' + p + ')' + ' is FALSE.');
    }
};
tell_me_the_truth('true');
tell_me_the_truth('false');
tell_me_the_truth('0');
tell_me_the_truth('1');
tell_me_the_truth('0.0');
tell_me_the_truth('NaN');
tell_me_the_truth('NaN === NaN');
tell_me_the_truth('isNaN(NaN)');
tell_me_the_truth('Infinity');
tell_me_the_truth('Infinity - 1');
tell_me_the_truth('Infinity - Infinity');
tell_me_the_truth('"0"');
tell_me_the_truth('"0.0"');
tell_me_the_truth('""');
tell_me_the_truth('[]');
tell_me_the_truth('{}');
tell_me_the_truth('null');
tell_me_the_truth('undefined');
tell_me_the_truth('!!undefined');
tell_me_the_truth('!!1');

Perl

  • NaN��'nan'+0��Inf��'inf'+0��
  • ¾�ˤ�()(���ꥹ��)�������󡢶��ϥå��夬����
  • �����ͥ�å��ʿ���1������''(��ʸ����;���ͥ���ƥ����ȤǤ�0����)
#!/usr/bin/perl
use strict;
use warnings;

our $nan = 'nan' + 0;
our $inf = 'inf' + 0;

sub tell_me_the_truth{
    my $s = shift;
    my $p = eval $s;
    local $\ = "\n"; # say
    if ($p){
        print "'$s' ($p) is TRUE."
    }
    else{
        print "'$s' ($p) is FALSE."
    }
};

tell_me_the_truth('0');
tell_me_the_truth('1');
tell_me_the_truth('0.0');
tell_me_the_truth('$nan');
tell_me_the_truth('$nan == $nan');
tell_me_the_truth('$inf');
tell_me_the_truth('$inf - 1');
tell_me_the_truth('$inf - $inf');
tell_me_the_truth('"0"');
tell_me_the_truth('"0.0"');
tell_me_the_truth('""');
tell_me_the_truth('my @a = ()');
tell_me_the_truth('my %h = ()');
tell_me_the_truth('[]');
tell_me_the_truth('{}');
tell_me_the_truth('undef');
tell_me_the_truth('!!undef');
tell_me_the_truth('!!1');

Python

  • NaN��float('nan')��Inf��float('inf')��
  • !�黻�ҤϤʤ��������bool()��Ȥ��롣
  • �����ͥ�å��ʿ���True������False
#!/usr/bin/python

nan = float('nan')
inf = float('inf')

def tell_me_the_truth(s):
    p = eval(s);
    if p:
        print "\'%s\' (%s) is TRUE." % (s, p)
    else:
        print "\'%s\' (%s) is FALSE." % (s, p)


tell_me_the_truth('True')
tell_me_the_truth('False')
tell_me_the_truth('0')
tell_me_the_truth('1')
tell_me_the_truth('0.0')
tell_me_the_truth('nan')
tell_me_the_truth('nan == nan')
tell_me_the_truth('inf')
tell_me_the_truth('inf - 1')
tell_me_the_truth('inf - inf')
tell_me_the_truth('"0"')
tell_me_the_truth('"0.0"')
tell_me_the_truth('""')
tell_me_the_truth('()')
tell_me_the_truth('{}')
tell_me_the_truth('[]')
tell_me_the_truth('None')
tell_me_the_truth('bool(None)')
tell_me_the_truth('bool(1)')

Ruby

  • NaN��0.0/0.0��Inf��1.0/0.0�Ǻ�뤳�Ȥ��Ǥ��뤬����ƥ��Ϥʤ��褦����
  • �����ͥ�å��ʿ���true������false
#!/usr/bin/ruby

@nan = 0.0/0.0
@inf = 1.0/0.0

def tell_me_the_truth(s)
    p = eval(s)
    if p
        puts "'#{s}' (#{p}) is TRUE."
    else
        puts "'#{s}' (#{p}) is FALSE."
    end
end

@elist = ();

tell_me_the_truth('true')
tell_me_the_truth('false')
tell_me_the_truth('0')
tell_me_the_truth('1')
tell_me_the_truth('0.0')
tell_me_the_truth('@nan')
tell_me_the_truth('@nan == @nan')
tell_me_the_truth('@inf')
tell_me_the_truth('@inf - 1')
tell_me_the_truth('@inf - @inf')
tell_me_the_truth('"0"')
tell_me_the_truth('"0.0"')
tell_me_the_truth('""')
tell_me_the_truth('@elist')
tell_me_the_truth('{}')
tell_me_the_truth('[]')
tell_me_the_truth('nil')
tell_me_the_truth('!!nil')
tell_me_the_truth('!!1')

Scheme

Ruby�ˤȤƤ���Ƥ��롣�Ȥ������Ruby���ȤƤ���Ƥ��롣

  • NaN��(/ 0 0)��Inf��(/ 1 0)�Ǻ�뤳�Ȥ��Ǥ��롣
  • #F�Τߵ����ʳ��������������ꥹ�Ȥ��鿿��
  • �����ͥ�å��ʿ���#T������#F
  • !!�Ϥʤ��������⤽��黻�ҤȤ����ͤ������Τ�Τ��ʤ����ؿ��ΤߤǤ��ꡢ!!�����̤�������뤳�Ȥ������
#!/usr/bin/gosh
(define (tell_me_the_truth s)
  (let ((p (eval s (interaction-environment))))
   (if p 
       (print "(" s ") " p " is TRUE")
       (print "(" s ") " p " is FALSE"))))

(define (! p) (not p))
(define (!! p) (not (not p)))

(tell_me_the_truth 0)
(tell_me_the_truth 1)
(tell_me_the_truth "")
(tell_me_the_truth '())
(tell_me_the_truth #f)
(tell_me_the_truth '(/ 0 0))
(tell_me_the_truth '(= (/ 0 0) (/ 0 0)))
(tell_me_the_truth '(/ 1 0))
(tell_me_the_truth '(- (/ 1 0) 1))
(tell_me_the_truth '(- (/ 1 0) (/ 1 0)))
(tell_me_the_truth '(! 1))
(tell_me_the_truth '(!! 1))

�ޤȤ�

�Ƹ���ˤ�����true/false�ޤȤ� - ���Υȥ륹�ȥ��������Ȥ���ȤΤ���
�ޤ�����ʴ����ǡ�����ˤ�äƿ����ͤλ���ϰۤʤ�Τǡ� if ʸ�Ǥ���ӱ黻�Ҥʤɤ��ά���ʤ������¿��Ǥ���!!

�ޤ��������ä�Ruby��Scheme�Ϥ��������ȡ�!�黻�Ҥ���ĸ���Ǥ���С������ͤ�������Τˤ�!!��Ȥ��Ȥ褤��

Dan the Man with Too Many Different Trues and Falses to Check