view include/operations.h @ 6:8676cf44c307

Added functions pow, dup, and drop pow pulls two numbers from the stack and raises the second pulled to the first pulled. This was implemented using a exp function I wrote previously and a log function I just wrote. If an integer power is requestion, it uses the standard O(log(n)) algorithm... This function can be called using '**' drop drops the top value of the stack and dup duplicates it... I also modified the make file so that it supports header file dependencies
author Jonathan Pevarnek <pevarnj@gmail.com>
date Sun, 06 Mar 2011 01:38:01 -0500
parents 90cd3d9a6ca3
children 089efc170bb0
line wrap: on
line source

#ifndef __OPERATIONS_H
#define __OPERATIONS_H

#include <std.h>
#include <stack.h>

enum Operation {PRINT, ADD, SUB, MULT, DIV, POW, DUP, DROP, MAXOP};
extern const char operationNames[MAXOP][10];
extern void (*operation[MAXOP])(struct Stack*);

void op_print(struct Stack *stack);
void op_add(struct Stack *stack);
void op_sub(struct Stack *stack);
void op_mult(struct Stack *stack);
void op_div(struct Stack *stack);
void op_pow(struct Stack *stack);
void op_dup(struct Stack *stack);
void op_drop(struct Stack *stack);

#endif //__OPERATIONS_H