S-Expression

This is a discussion on S-Expression within the C++ Programming forums, part of the General Programming Boards category; Could anyone tell me anything about S-Expressions in C++ and how I would go about using it with a binary ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    81

    S-Expression

    Could anyone tell me anything about S-Expressions in C++ and how I would go about using it with a binary search tree?

    I appreciate any comments, thanks!
    "Our greatest glory consists not in never failing,
    but in rising every time we fall."

    Oliver Goldsmith (1730-1774).
    Anglo-Irish writer, poet and playwright.

  2. #2
    ggs
    ggs is offline
    C > C++ duders ggs's Avatar
    Join Date
    Aug 2001
    Posts
    435
    an s-expression is like this:

    ((wut woah huh) wut wut)

    nested lists

    so, you take your basic binary tree definition:

    tree {
    item item
    tree right, left
    }

    and instead of treating right as `right', treat it as 'nest'

    so for every ( you encounter, open a new level of your `tree' and store everything you encounter up until ) in something pointed to by right

    use left to point to the next node in your list of items

    ex:
    ( wut ( woah ) )

    to:

    node 1
    item - wut
    left - null
    right - node 2

    node 2
    item - woah
    left - null
    right - null

    i hope i am coherent
    .sect signature

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help with making a Math Expression DLL
    By MindWorX in forum C Programming
    Replies: 19
    Last Post: 07-20-2007, 12:37 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 03:39 PM
  3. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21