Example #1
0
File: tries.c Project: edechter/yap
static int p_trie_print(void) {
  /* check arg */
  if (!YAP_IsIntTerm(arg_trie))
    return FALSE;

  /* print trie */
  trie_print((TrEntry) YAP_IntOfTerm(arg_trie));
  return TRUE;
}
Example #2
0
void trie_print(trie* t, char* text, int length) {
    int i = 0;
    for (i = 0; i < t->count; i++) {
        trie* x = &(t->children[i]);
        text[length++] = x->letter;
        if (x->count < 1) {
            text[length] = '\0';
            printf("%s\n", text);
        }
        else if (x->leaf) {
            text[length] = '\0';
            printf("%s\n", text);
            text[length] = '_';
            trie_print(x, text, length);
        }
        else {
            trie_print(x, text, length);
        }
        length--;
    }
}