1use crate::func_impl::*;
2use crate::term_reference::*;
3use std::cmp::*;
4use std::fmt::*;
5use std::hash::*;
6use crate::displayable_with_state::*;
7use crate::displayable_with_context::*;
8use crate::interpreter_state::*;
9use crate::primitive_term_pointer::*;
10
11#[derive(Clone, Hash, PartialEq, Eq)]
15pub struct PartiallyAppliedTerm {
16 pub func_ptr : PrimitiveTermPointer,
17 pub args : Vec<TermReference>
18}
19
20impl DisplayableWithState for PartiallyAppliedTerm {
21 fn display(&self, state : &InterpreterState) -> String {
22 let mut result = String::from("");
23 let func_formatted : String = self.func_ptr.display(state.get_context());
24 result.push_str(&func_formatted);
25 result.push_str("(");
26
27 let mut done_once : bool = false;
28
29 for arg in self.args.iter() {
30 if (done_once) {
31 result.push_str(", ");
32 }
33 let arg_formatted : String = arg.display(state);
34 result.push_str(&arg_formatted);
35 done_once = true;
36 }
37 result.push_str(")");
38 result
39 }
40}
41
42impl PartiallyAppliedTerm {
43 pub fn new(func_ptr : PrimitiveTermPointer) -> PartiallyAppliedTerm {
46 PartiallyAppliedTerm {
47 func_ptr,
48 args : Vec::new()
49 }
50 }
51}