Coder Profile - Show off your skills, get a coder profile.
 
 
 
The Author
Cinjection
Oleksi Derkatch
Send A Message
Rating
Not
Rated
Please login to rate source codes.

Click here to register a free account with us.
General Details
Scheme
Posted 94 Days Ago
214 Views
Received 0 Ratings
More Codes By This Author
MD5 Brute-Forcer
Number of ways to make ch...
SPS Desktop Changer
Simple program using GUI...
Genetic Algorithm for sol...
Articles By This Author
Intorduction to memoizati...
Strings in C++
Vectors in C++
Use Cases
[C++] Pointers and their...

Pre, in, post order traversal of a binary tree.


Description
Here's an example of traversing a binary tree in three different ways, pre-order, in-order, and post-order. I made the functions bracket the expressions so that they are easier to read. For instance, 2 * 4 + 5 * 6 is actually printed as ( (2 * 4) + (5 * 6) ).

This program is the first step in a little app I want to make that can convert infix notation (like 2 + (4 / (3+5)) - (4 + 4) ) into Scheme's pre-fix notation. (like: (- (+ 2 (/ 4 (+ 3 5))) (+ 4 4)) )

This program could then be used to help beginner Scheme programmers understand complicated arithmetic operations in pre-fix notation. The only thing I need to figure out is how Scheme handles string processing. If someone knows how to do this, could they point me in the right direction? I might just make a C++ front-end that accesses this code, which I also have to explore.

Please let me know if there are any ways that I can improve this code. Thanks.
Technical
Output:
(+ (* 2 3 )(* 4 5 ))
((2 * 3 )+ (4 * 5 ))
((2 3 * )(4 5 * )+ )
Source Code
Comments
Please login to post comments.
 
Cinjection     Posted 87 Days Ago
 
 
Good point
 
closure     Posted 91 Days Ago
 
 
Hi,

you might want to look at srfi-13 for string procedures. But why bother strings,
when you can work on lists? :)
Page 1 of 1
More "Scheme" Source Codes By This Author
Recently Posted "Scheme" Source Codes
Recently Rated "Scheme" Source Codes
 
 
Part of the MyPingle Network
Development Blog :: Make A Donation :: Contact Me
Terms & Conditions :: Privacy Policy :: Documents
Version 1.44.00
Copyright © 2007 - 2008, Scott Thompson, All Rights Reserved