Obj transformDelay(Obj expr) { List* list = makeList(LAMBDAOBJ, makeList(NULLOBJ, makeList(delayExpr(expr), NULL))); Obj obj = LISTOBJ(list); return obj; }
int main(void) { list_t* list1 = makeList(); list_t* list2 = makeList(); node_t* nodeArr1[NUM_OF_NODE] = { 0, }; node_t* nodeArr2[NUM_OF_NODE] = { 0, }; for (int i = 0; i < NUM_OF_NODE; i++) { nodeArr1[i] = makeNode(2 * (i + 1)); nodeArr2[i] = makeNode(3 * i + 1); if (i) { nodeArr1[i - 1]->next = nodeArr1[i]; nodeArr2[i - 1]->next = nodeArr2[i]; } else { list1->head = nodeArr1[i]; list2->head = nodeArr2[i]; } } printf("리스트 1\n"); printList(list1->head); printf("리스트 2\n"); printList(list2->head); printf("머지 리스트\n"); printList(merge(list1, list2)->head); return 0; }
// complete algorithm to compute a Groebner basis F void gb( IntermediateBasis &F, int n) { int nextIndex = F.size(); rearrangeBasis(F, -1); interreduction(F); Pairs B = makeList(F, n); //unsigned int countAddPoly = 0; //unsigned int numSPoly= 0; int interreductionCounter = 0; while (!B.empty()) { Pair pair = *(B.begin()); B.erase(B.begin()); if (isGoodPair(pair,F,B,n)) { //numSPoly++; BRP S = sPolynomial(pair,F,n); reduce(S,F); if ( ! S.isZero() ) { //countAddPoly++; F[nextIndex] = S; if(interreductionCounter == 5) { interreductionCounter = 0; interreduction(F); B = makeList(F, n); } else { interreductionCounter++; Pairs newList = makeNewPairs(nextIndex, F, n); B.insert(newList.begin(), newList.end()); } nextIndex++; } } } interreduction(F); //cout << "we computed " << numSPoly << " S Polynomials and added " << countAddPoly << " of them to the intermediate basis." << endl; }
int main(int argc, char *argv[]) { if (argc != 3) { printf("Usage ./%s <num1> <num2>", argv[0]); return (-1); } Node *num1 = NULL; Node *num2 = NULL; num1 = (Node *) malloc(sizeof (Node)); num2 = (Node *) malloc(sizeof (Node)); num1->dig = argv[1][0] - '0'; num2->dig = argv[2][0] - '0'; num1->next = NULL; num2->next = NULL; makeList(num1, argv[1]); makeList(num2, argv[2]); Node *num3; num3 = addList(num1, num2); Node *temp = num3; while (temp) { printf("%d", temp->dig); temp = temp->next; } printf("\n"); freeMem(num1); freeMem(num2); freeMem(num3); return (0); }
// Recursive solution to add to the tail of list l. Note: This code is slightly // messy! Node *addToTail(Node *l, int v){ if(!l) // List is null, make a new one and return return makeList(v); if(!l->next){ // Next is null, i.e. at the tail, add node and return l->next = makeList(v); return l; // This return does nothing, simply eliminates need for wrapper } addToTail(l->next, v); return l; }
Obj makeFunc(Obj params, Obj body, Obj env) { List* list = makeList(NAMEOBJ(FUN_KEY), makeList(params, makeList(body, makeList(env, NULL)))); Obj obj = LISTOBJ(list); return obj; }
Node *addToTail(Node *l, int v){ if(!l) return makeList(v); Node *iter = l; while(iter->next){ iter = iter->next; } iter->next = makeList(v); return l; }
/* Function name: addToTail * Description: Adds a node with value v to the end of list l. If l is * NULL, returns a new list with a node of value v. * Return: Returns a pointer to the new list. * Parameters * - l: An existing list. * - v: The value of the new node. * Failure cases: None. */ Node *addToTail(Node *l, int v){ if(!l) return makeList(v); Node *iter = l; while(iter->next){ // Set iter to the next to last node iter = iter->next; } iter->next = makeList(v); return l; }
Node *insertAtN(Node *l, int v, int n){ if(!l) return makeList(v); if(n == 0){ return addToHead(l, v); } Node *before = traverseToN(l, n-1); assert(before); Node *after = before->next; before->next = makeList(v); before->next->next = after; return l; }
Obj transformOr(Obj expr) { Obj seq = boolExps(expr); if (noExps(seq)) return FALSEOBJ; Obj first = firstExp(seq); List* cdr = GETLIST(seq)->cdr; Obj rest = LISTOBJ(makeList(OROBJ, cdr)); List* ifTrans = makeList( IFOBJ, makeList(first, makeList(TRUEOBJ, makeList(rest, NULL)))); return LISTOBJ(ifTrans); }
int main() { List* list = makeList(); // Set a print function so that we may call printList setPrintFun(list, printFloat); printList(list); // Add ten elements for (int i = 0; i < 9; ++i) { append(list, 5.0); } // Force a resize append(list, 1.5); append(list, 9.3); append(list, 3.5); // Print the list in its current state printList(list); // Sort the list, using the comparison function we set setCmpFun(list, ascend); sort(list); printList(list); // It's the caller's responsibility to call this cleanupList(list); return EXIT_SUCCESS; }
int testDatastruct() { Sample * sample = (Sample *)malloc(sizeof(Sample)); sample->x = 0.1; sample->y = 0.2; sample->z = 0.3; LinkedList * list = makeList(); printf("APPENDING TEST...\n"); for (int i = 0; i < 100; i++) { add(*sample, list); } toStringList(list); printf("\n"); printf("SANDWICHING TEST...\n"); for (int i = 0; i < 100; i++) { addI(i, *sample, list); } toStringList(list); printf("Getting x series...\n"); acc * xs = getSubSeries(X, 0, list->count - 1, list); acc * current = xs; while ((long)(*(current++)) != TERMINATION_VALUE) { printf("next: %2.3f\n", *current); } puts("Finished."); getchar(); }
char * getTagItemString(int type, char * string) { ListNode * node; int pos; /*if(type == TAG_ITEM_TITLE) return strdup(string);*/ if(tagLists[type] == NULL) { tagLists[type] = makeList(free, 1); sortList(tagLists[type]); } if(findNodeInList(tagLists[type], string, &node, &pos)) { ((TagTrackerItem *)node->data)->count++; } else { TagTrackerItem * item = malloc(sizeof(TagTrackerItem)); item->count = 1; item->visited = 0; node = insertInListBeforeNode(tagLists[type], node, pos, string, item); } return node->key; }
int main(int argc, char *argv[]){ if(argc != 3){ usage(argv[0], stderr); exit(1); } FILE *inputFile = fopen(argv[1], "r"); if(NULL == inputFile){ fprintf(stderr, "File %s not exist.\n", argv[1]); exit(1); } FILE *outputFile = fopen(argv[2], "w"); List *list = makeList(inputFile); removeInvalidData(list); lowPassFilter(list); setStatus(list); outputResult(list, outputFile); fclose(inputFile); fclose(outputFile); freeList(list); return 0; }
Expr builtin(Type t, const std::string &name, Expr a) { MLVal args = makeList(); args = addToList(args, a.node()); Expr e(makeExternCall(t.mlval, name, args), t); e.child(a); return e; }
env_t makeEnv(env_t *parent) { env_t newEnv; newEnv.vars = makeList(); newEnv.parent = parent; return newEnv; }
/* Function name: insertAtN * Description: Inserts a new node BEFORE the Nth node of l. That is, the * inserted node becomes the Nth node. If l is NULL and n is * 0, returns a new list with a node of value v. * Return: The new list. * Parameters * - l: An existing list. * - v: The value of the new node. * - n: The place to insert into. * Failure cases: If n < 0 or n > length(l), then an assertion will be * triggered, and a NULL list returned. */ Node *insertAtN(Node *l, int v, int n){ myassert(nIsInRange(l, n)); if(!l) return makeList(v); if(n == 0){ return addToHead(l, v); } // Set before to the node before the place to insert Node *before = traverseToN(l, n-1); Node *after = before->next; // Save the current next Node *newNode = makeList(v); // Create the new node before->next = newNode; // Link the previous nodes to the new node newNode->next = after; // Link the new node to the posterior nodes return l; }
int main () { printf ("Enter number of people "); int numb = 0; scanf("%d", &numb); printf("Enter step "); int step = 0; scanf("%d", &step); List *list = new List; ListElement *head = new ListElement; list->first = head; makeList(list, numb); printList(list, numb); printf("%d", findNumb(list, numb, step)); /*if (step == 1) { delete(list->first->next); } else { delete }*/ delete(list); delete(head); scanf("%d", &step); }
QVariant ListRegistrarsCommand::operator()(const QVariantMap &request) { BitProfile::MasterRegistrar master(_provider, GetBitprofileNetwork(_settings)); BitProfile::MasterRegistrar::URIList uris = master.getURIList(); return makeList(request.contains("offset")?uris.at(request["offset"].toInt()): uris.begin(), uris.end(), request.contains("limit")?request["limit"].toInt():100); }
int main() { int num1, num2; printf("Enter two numbers: "); scanf("%d %d", &num1, &num2); if (num1 < 0 || num2 < 0) { return 0; } struct node *h1 = makeList(num1); struct node *h2 = makeList(num2); struct node *h3 = addLists(h1, h2); // sum list printf("\nSum: "); displayNum(h3); return 0; }
int main() { int a[] = {1, 2, 3, 4, 5}; ListNode *lst = makeList(a, 5); Solution s; ListNode *ret = s.rotateRight(lst, 5); prList(ret); return 0; }
int main() { int a[] = {1, 2, 3, 4, 5}; ListNode *lst = makeList(a, 5); prList(lst); Solution s; ListNode *ret = s.reverseBetween(lst, 2, 4); prList(ret); return 0; }
int main() { List l = makeList(10); PrintList(l); std::cout << "------" << std::endl; l = reverseLinkedList(l); PrintList(l); return 0; }
void initInputPlugins() { inputPlugin_list = makeList(NULL, 1); /* load plugins here */ loadInputPlugin(&mp3Plugin); loadInputPlugin(&oggPlugin); loadInputPlugin(&flacPlugin); loadInputPlugin(&audiofilePlugin); loadInputPlugin(&mp4Plugin); loadInputPlugin(&modPlugin); loadInputPlugin(&aacPlugin); }
Expr::Expr(const ImageRef &l) { MLVal args = makeList(); for (size_t i = l.idx.size(); i > 0; i--) { args = addToList(args, l.idx[i-1].node()); } MLVal node = makeImageCall(l.image.type().mlval, l.image.name(), args); contents.reset(new ExprContents(node, l.image.type())); for (size_t i = 0; i < l.idx.size(); i++) { child(l.idx[i]); } contents->images.push_back(l.image); }
int main() { int arr[] = {1,2}; struct ListNode *h = makeList(arr, 2); h = reverseListRec(h); // reverseListRec(NULL); printList(h); return 0; }
static Object makeList() { Object head; Token *token = getToken(); if (token->type == tCLOSE_PAREN) { return nil; } else { putBackToken(); head = read(); return cons(head, makeList()); } }
Expr debug(Expr e, const std::string &prefix, const std::vector<Expr> &args) { MLVal mlargs = makeList(); for (size_t i = args.size(); i > 0; i--) { mlargs = addToList(mlargs, args[i-1].node()); } Expr d(makeDebug(e.node(), (prefix), mlargs), e.type()); d.child(e); for (size_t i = 0; i < args.size(); i++) { d.child(args[i]); } return d; }
void testMakeList(){ int testCases[] = {8, 'n', -1, 149327859816738, -583492752983568732}; for(int i = 0 ; i < (int)getArrLen(testCases) ; i++){ Node *list; list = makeList(testCases[i]); printList(list); #if DELETE_DEFINED delList(list); #endif } printf(">> Test make list completed! <<\n"); }
int main() { List *list = makeList(); initialiseList(list); int i; for(i=0; i<10; i++) { appendItem(list, i); } printf("end!\n"); printList(list); return 0; }