(define (count x y)
(if (<= x y)
(cons
x (count (+ 1 x) y))))
Answer to Question #18
(define (check x)
(if (null? x)
1
(if (null?
(cdr x))
1
(if (> (car x) (car (cdr x)))
0
(check (cdr x))
)
)
)
)
Answer to Question #17
#!/usr/bin/perl -w
for($i = 1; $i <= 10; $i++) {
print "$i\n";
}
Answer to Question #18
#!/usr/bin/perl -w
# First load up the dictionary
open(DICT, "</usr/dict/words") || die "Unable
to open dict";
while( $word = <DICT> ) {
$words{$word}
= 1;
}
# Get words to look up
print "Enter a word to look up\n";
while ($word = <STDIN>) {
if (defined($words{$word}))
{
print "Found\n";
}
else {
print "No Found\n";
}
print
"Enter a word to look up\n";
}
Another Answer to Question #18
#!/usr/bin/perl -w
$word=$ARGV[0];
open(FH, "</usr/dict/words") || die "File doesnt
exist";
while($line=<FH>){
if(index($line,
$word)>=0)
{
print "This is a real word";
exit(1);
}
}