[plt-scheme] Scheme Programming Question (Boolean Connectives)
Um,
It helps if you provide a little more information on how far you have
got working it out for yourself?
I think looing at http://www.htdp.org/ and http://www.scheme.com/tspl3/
(How to Design Programs and The Scheme Programming Language in online
versions)
provide valuable advice and examples that should help.
Cheers,
Stephen
--
Stephen De Gabrielle
s.degabrielle at cs.ucl.ac.uk
Telephone +44 (0)20 7679 0693 (x30693)
Mobile 079 851 890 45
Project: Making Sense of Information (MaSI)
Work:http://www.uclic.ucl.ac.uk/annb/MaSI.html
Home:http://www.degabrielle.name/stephen
UCL Interaction Centre
MPEB 8th floor
University College London
Gower Street
London WC1E 6BT
On Sat, Oct 4, 2008 at 6:13 PM, Geneve <kyung8653 at gmail.com> wrote:
> This is another problem that I am having trouble with.
> I really need your help.
>
>
> Question Details:
> Exercise 7. The built-in predicate string<? accepts two strings and
> returns true if its arguments are given in lexicographic order, i.e.,
> "alphabetical order," where our alphabet includes numeric and special
> characters as well as alphbetic characters. That is, (string<? s1 s2)
> evaluates to true if s1 is a proper prefix of s2 or if there is a
> character c1 in s1 and c2 in s2 where (char<? c1 c2) and the (possibly
> empty) prefix of s1 up to (but not including) c1 is equal to the
> prefix of s2 up to (but not including) c2.
>
>
>
> Define a procedure string<?. Use an internally-defined help procedure
> and the built-in procedures char<?, char=?, and string->list in your
> solution, but do not use the built-in string<? or other string
> comparison predicates. Experiment with test cases of your own using
> the built-in string<? procedure before loading your own definition.
>
>
>
>> (string<? "abc" "abc")
>
> #f
>
>> (string<? "aaaa" "aaaaaaa")
>
> #t
>
>> (string<? "abcdefg" "abcdefh")
>
> #t
>
>> (string<? "abcdefg" "abcdeff")
>
> #f
>
>> (string<? "walk" "crawl")
>
> #f
>
>> (string<? "bark" "dog")
>
> #t
>
>> (string<? "dog" "bark")
>
> #f
>
>> (string<? "!@#$%&*(" "!@#%&*(")
>
> #t
>
>
>
> Hint: Use a local help procedure that expects two lists of characters.
> Remember that the two lists may have different lengths, and think
> carefully about termination conditions in different cases. If neither
> list is empty, the help procedure compares the first characters of the
> two lists, and loops only if the two characters are equal. Using and
> and or should simplify your code.
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>