# [plt-scheme] Scheme Programming Question (Boolean Connectives)

 From: Stephen De Gabrielle (s.degabrielle at cs.ucl.ac.uk) Date: Sun Oct 5 04:14:00 EDT 2008 Previous message: [plt-scheme] Scheme Programming Question (Boolean Connectives) Next message: [plt-scheme] Scheme Programming Question (Boolean Connectives) Messages sorted by: [date] [thread] [subject] [author]

```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
>
>
>
>> (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.
> _________________________________________________