Search Results

Search found 36179 results on 1448 pages for 'generic list'.

Page 24/1448 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • nvidia driver problems after upgrading to 3.2.0-26 on Ubuntu 12.04 64bit

    - by Lev Levitsky
    After installing latest updates I can't set screen resolution higher than 1024x768; every time after the boot I get a message Could not apply the stored configuration for the monitors (Note: removing ~/.config/monitors.xml stopped the message, but not the problem) I can boot with 3.2.0-25 and the graphics look normal. Here's what I have in /var/log/apt/term.log (excerpt): Setting up linux-image-3.2.0-26-generic (3.2.0-26.41) ... Running depmod. update-initramfs: deferring update (hook will be called later) Examining /etc/kernel/postinst.d. run-parts: executing /etc/kernel/postinst.d/dkms 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic Error! Problems with depmod detected. Automatically uninstalling this module. DKMS: Install Failed (depmod problems). Module rolled back to built state. run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic update-initramfs: Generating /boot/initrd.img-3.2.0-26-generic run-parts: executing /etc/kernel/postinst.d/pm-utils 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic run-parts: executing /etc/kernel/postinst.d/update-notifier 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic run-parts: executing /etc/kernel/postinst.d/zz-update-grub 3.2.0-26-generic /boot/vmlinuz-3.2.0-26-generic Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.2.0-26-generic Found initrd image: /boot/initrd.img-3.2.0-26-generic Found linux image: /boot/vmlinuz-3.2.0-25-generic Found initrd image: /boot/initrd.img-3.2.0-25-generic Found linux image: /boot/vmlinuz-3.2.0-24-generic Found initrd image: /boot/initrd.img-3.2.0-24-generic Found linux image: /boot/vmlinuz-3.2.0-23-generic Found initrd image: /boot/initrd.img-3.2.0-23-generic Found linux image: /boot/vmlinuz-3.0.0-17-generic Found initrd image: /boot/initrd.img-3.0.0-17-generic Found memtest86+ image: /boot/memtest86+.bin I went to "additional drivers" and saw some updates available there, but an attempt to install them failed, leaving the following in /var/log/jockey.log (long log, pasted here). The full log won't fit in the question, so I'm showing $ fgrep 'ERROR' /var/log/jockey.log 2012-06-30 17:29:57,897 WARNING: modinfo for module vmxnet failed: ERROR: modinfo: could not find module vmxnet 2012-06-30 17:29:57,937 WARNING: modinfo for module wl failed: ERROR: modinfo: could not find module wl 2012-06-30 17:29:58,072 WARNING: modinfo for module nvidia_96 failed: ERROR: modinfo: could not find module nvidia_96 2012-06-30 17:29:58,240 WARNING: modinfo for module nvidia_current failed: ERROR: modinfo: could not find module nvidia_current 2012-06-30 17:29:58,293 WARNING: modinfo for module nvidia_current_updates failed: ERROR: modinfo: could not find module nvidia_current_updates 2012-06-30 17:29:58,351 WARNING: modinfo for module nvidia_173_updates failed: ERROR: modinfo: could not find module nvidia_173_updates 2012-06-30 17:29:58,385 WARNING: modinfo for module nvidia_173 failed: ERROR: modinfo: could not find module nvidia_173 2012-06-30 17:29:58,420 WARNING: modinfo for module nvidia_96_updates failed: ERROR: modinfo: could not find module nvidia_96_updates 2012-06-30 17:29:58,455 WARNING: modinfo for module ath_pci failed: ERROR: modinfo: could not find module ath_pci 2012-06-30 17:29:58,478 WARNING: modinfo for module fglrx_updates failed: ERROR: modinfo: could not find module fglrx_updates 2012-06-30 17:29:58,531 WARNING: modinfo for module fglrx failed: ERROR: modinfo: could not find module fglrx 2012-06-30 17:29:58,588 WARNING: modinfo for module omapdrm_pvr failed: ERROR: modinfo: could not find module omapdrm_pvr 2012-06-30 17:29:59,537 WARNING: modinfo for module nvidia_current failed: ERROR: modinfo: could not find module nvidia_current 2012-06-30 17:29:59,613 WARNING: modinfo for module nvidia_173_updates failed: ERROR: modinfo: could not find module nvidia_173_updates 2012-06-30 17:29:59,686 WARNING: modinfo for module nvidia_173 failed: ERROR: modinfo: could not find module nvidia_173 2012-06-30 17:29:59,764 WARNING: modinfo for module nvidia_current_updates failed: ERROR: modinfo: could not find module nvidia_current_updates 2012-06-30 17:30:29,544 WARNING: modinfo for module nvidia_current_updates failed: ERROR: modinfo: could not find module nvidia_current_updates 2012-06-30 17:30:29,545 ERROR: XorgDriverHandler.enable(): package or module not installed, aborting I'm not sure if it's a bug, as the first log shows some errors. What can I try?

    Read the article

  • How to generate SPMetal for a specific list (OOTB: like tasks or contacts) with custom columns

    - by KunaalKapoor
    SPMetal is used to make use of LINQ on a list in SharePoint 2010. By default when you generate SPMetal on a site you will get a code generated file for most of the lists and probably more. Here is a MSDN link for some info on SPMetal.http://msdn.microsoft.com/en-us/library/ee538255(office.14).aspxBut what if you want only to generate the code for one list?Well it is quite simple once you figure it out. You need to add an xml file to override the default settings of SPMetal and specify it in the /parameters option. I will show you how to do this.First create a Folder that will contain two files (GenerateSPMetalCode.bat and SPMetal.xml).Below is the content of the files:GenerateSPMetalCode.bat "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal" /web:http://YourServer /code:OutPutFileName.cs /language:csharp /parameters:SPMetal.xml pause SPMetal.xml <?xml version="1.0" encoding="utf-8"?> <Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal"> <List Name="ListName"> <ContentType Name="ContentTypeName" Class="GeneratedClassName" /> </List> <ExcludeOtherLists></ExcludeOtherLists> </Web> You will have to change some of the text in the files so that it will be specific to your SharePoint Server Setup. In the bat file you will have to change http://YourServer to the url of the web where your list is. In the SPMetal.xml file you need to change ListName to the name of your list and the ContentTypeName to the name of the content type you want to extract. The GeneratedClassName can be anything but perhaps you should rename it to something more sensible.Adding the following line: '<List Name="ListName"><ContentType Name="ContentTypeName" Class="GeneratedClassName" /> </List>'  makes sure that any custom columns added to an OOTB list like contacts or tasks are also generated, which are missed out in a regular generation.So now when you run it the SPMetal command will read the SPMetal.xml list and override its commands. ExcludeOtherLists element makes it so that only the code for the lists you specify will be generated. For some reason I got an error if I had this element above the List element.You sould now have a code file called OutPutFileName.cs that has been generated. You can now put this in your SharePoint project for use with your LINQ queries against that list.I will soon write a LINQ example that uses the generated class. UPDATE: Add the /namespace parameter to add a namespace to the generated code. "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal" /web:http://YourServer /namespace:MySPMetalNameSpace /code:OutPutFileName.cs /language:csharp /parameters:SPMetal.xml

    Read the article

  • How to select a rectangle from List<Rectangle[]> with Linq

    - by dboarman
    I have a list of DrawObject[]. Each DrawObject has a Rectangle property. Here is my event: List<Canvas.DrawObject[]> matrix; void Control_MouseMove ( object sender, MouseEventArgs e ) { IEnumerable<Canvas.DrawObject> tile = Enumerable.Range( 0, matrix.Capacity - 1) .Where(row => Enumerable.Range(0, matrix[row].Length -1) .Where(column => this[column, row].Rectangle.Contains(e.Location))) .????; } I am not sure exactly what my final select command should be in place of the "????". Also, I was getting an error: cannot convert IEnumerable to bool. I've read several questions about performing a linq query on a list of arrays, but I can't quite get what is going wrong with this. Any help? Edit Apologies for not being clear in my intentions with the implementation. I intend to select the DrawObject that currently contains the mouse location.

    Read the article

  • SPPersistedObject and List<T>

    - by Sam
    Hi I want sharepoint to "persist" a List of object I wrote a class SPAlert wich inherit from SPPersistedObject : public class SMSAlert: SPPersistedObject { [Persisted] private DateTime _scheduledTime; [Persisted] private Guid _listId; [Persisted] private Guid _siteID; } Then I wrote a class wich inherit from SPJobDefinition an add a List of my previous object: public sealed class MyCustomJob: SPJobDefinition { [Persisted] private List<SMSAlert> _SMSAlerts; } The problem is : when I call the Update method of y MyCustomJob: myCustomJob.Update(); It throw an exception : message : An object in the SharePoint administrative framework, depends on other objects which do not exist. Ensure that all of the objects dependencies are created and retry this operation. stack at Microsoft.SharePoint.Administration.SPConfigurationDatabase.StoreObject(SPPersistedObject obj, Boolean storeClassIfNecessary, Boolean ensure) at Microsoft.SharePoint.Administration.SPConfigurationDatabase.PutObject(SPPersistedObject obj, Boolean ensure) at Microsoft.SharePoint.Administration.SPPersistedObject.Update() at Microsoft.SharePoint.Administration.SPJobDefinition.Update() at Sigi.Common.AlertBySMS.SmsAlertHandler.ScheduleJob(SPWeb web, SPAlertHandlerParams ahp) inner exception An object in the SharePoint administrative framework depends on other objects which do not exist. The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dependencies1_Objects". The conflict occurred in database "SharePoint_Config, table "dbo.Objects", column 'Id'. The statement has been terminated. Can anyone help me with that??

    Read the article

  • How to Object Array to List

    - by Peter Black
    (C#) I have 2 classes. 1 is called Employee. The other is my "main". I am trying to take a list and assign each value in list to an array of Employee object. //Inside "Main" class int counter = NameList.Count; Employee[] employee = new Employee[counter]; for (int i = 0; i <= counter; i++) { employee[i].Name = NameList[i]; employee[i].EmpNumber = EmpNumList[i]; employee[i].DateOfHire = DOHList[i]; employee[i].Salary = SalaryList[i]; employee[i].JobDescription = JobDescList[i]; employee[i].Department = DeptList[i]; } This returns the error: An unhandled exception of type 'System.NullReferenceException' occurred in Pgm4.exe Additional information: Object reference not set to an instance of an object. I think this means that I am not calling the list properly. Any help would be much appreciated. Thank you.

    Read the article

  • How to access the element of a list/vector that passed by reference in C++

    - by bsoundra
    Hi all, The problem is passing lists/vectors by reference int main(){ list<int> arr; //Adding few ints here to arr func1(&arr); return 0; } void func1(list<int> * arr){ // How Can I print the values here ? //I tried all the below , but it is erroring out. cout<<arr[0]; // error cout<<*arr[0];// error cout<<(*arr)[0];//error //How do I modify the value at the index 0 ? func2(arr);// Since it is already a pointer, I am passing just the address } void func2(list<int> *arr){ //How do I print and modify the values here ? I believe it should be the same as above but // just in case. } Is the vectors any different from the lists ? Thanks in advance. Any links where these things are explained elaborately will be of great help. Thanks again.

    Read the article

  • python matrices - list index out of range

    - by user1888493
    I am writing a function, that takes a matrix as input, such as the one below. Then the it returns the matrix' inverse, where all the 1s are changed to 0s and all the 0s changed to 1s, while keeping the diagonal from top left to bottom right 0s. An example input: g1 = [[0, 1, 1, 0], [1, 0, 0, 1], [1, 0, 0, 1], [0, 1, 1, 0]] the function should output this: g1 = [[0, 0, 0, 1], [0, 0, 1, 0], [0, 1, 0, 0], [1, 0, 0, 0]] When I run the program, it raises a list index out of range error. I'm sure this happens, because the loops I have set up are trying to access values that do not exist. But how do I allow an input of unknown row and column size? I only know how to do this with a single list, but a list of lists? Following you see the transforming function, but not the test function that calls it: def inverse_graph(graph): # take in graph # change all zeros to ones and ones to zeros r, c = 0, 0 # row, column equal zero while (graph[r][c] == 0 or graph[r][c] == 1): # while the current row has a value. while (graph[r][c] == 0 or graph[r][c] == 1): # while the current column has a value if (graph[r][c] == 0): graph[r][c] = 1 elif (graph[r][c] == 1): graph[r][c] = 0 c+=1 c=0 r+=1 c=0 r=0 # sets diagonal to zeros while (g1[r][c] == 0 or g1[r][c] == 1): g1[r][c]=0 c+=1 r+=1 return graph

    Read the article

  • Meaning of NEXT in Linked List creation in perl

    - by seleniumnewbie
    So I am trying to learn Linked Lists using Perl. I am reading "Mastering Algorithms with Perl" by Job Orwant. In the book he explains how to create a linked list I understand most of it, but I just simply fail to understand the command/index/key NEXT in the second last line of the code snippet. $list=undef; $tail=\$list; foreach (1..5){ my $node = [undef, $_ * $_]; $$tail = $node; $tail = \${$node->[NEXT]}; # The NEXT on this line? } What is he trying to do there? Isn $node a scalar, which stores the address of the unnamed array. Also even if we are de-referencing $node, should we not refer to the individual elements by an index number example (0,1). If we do use "NEXT" as a key, is $node a reference to a hash? I am very confused. Something in plain English will be highly appreciated.

    Read the article

  • looping array inside list in c#

    - by 3yoon af
    I have a list of array that contains multiple arrays. each array has 2 index .. First, I want to loop the list. Then i want to loop the array inside the list .. How can i do that ? I try to use this way, but it doesn't work ! foreach (string[] s in ArrangList1) { int freq1 = int.Parse(s[1]); foreach (string[] s1 in ArrangList) { int freq2 = int.Parse(s1[1]); if (freq1 < freq2) { backup = s; index1 = ArrangList1.IndexOf(s); index2 = ArrangList.IndexOf(s1); ArrangList[index1] = s1; ArrangList[index2] = s; } backup = null; } } it give me error in line 4.. I try to do the loop using other way .. but i don't know how to continue ! for (int i = 0; i < ArrangList1.Count; i++) { for (int j = 0; j < ArrangList1[i].Length; j++) { ArrangList1[i][1]; } } I use C# language .. Can someone help me, please?

    Read the article

  • Python & Pygame: Updating all elements in a list under a loop during iteration

    - by Unit978
    i am working on a program in Python and using Pygame. this is what the basic code looks like: while 1: screen.blit(background, (0,0)) for event in pygame.event.get(): if event.type == QUIT: pygame.quit() sys.exit() if event.type == KEYDOWN and event.key == K_c: circle_create = True circle_list.append(Circle()) if event.type == MOUSEBUTTONDOWN and circle_create == True: if clicks == 0: circle_list[i].center() clicks += 1 if event.type == MOUSEMOTION and clicks == 1 and circle_create == True: circle_list[i].stretch() these if statements are under the while loop not the for loop since they dont require input from the user if circle_create == True: circle_list[i].draw_circle() if clicks == 2: clicks = 0 i += 1 circle_create = False pygame.display.update() what i want to do is have the object's function of draw_circle() to be constantly updated by the loop so that the drawn circle is shown for all objects in the list, but since the list is iterated it updates the new object added and the objects already appended are not updated. The program, works, it draws the circles upon user input but the update problem is the only issue i need to solve. Is there any possible way to have all elements in the list of objects being updated by the while loop? i have tried for many days and i have not been able to find a good solution. any ideas are appreciated. Thanks

    Read the article

  • How to implement a Linked List in Java?

    - by nbarraille
    Hello! I am trying to implement a simple HashTable in Java that uses a Linked List for collision resolution, which is pretty easy to do in C, but I don't know how to do it in Java, as you can't use pointers... First, I know that those structures are already implemented in Java, I'm not planning on using it, just training here... So I created an element, which is a string and a pointer to the next Element: public class Element{ private String s; private Element next; public Element(String s){ this.s = s; this.next = null; } public void setNext(Element e){ this.next = e; } public String getString(){ return this.s; } public Element getNext(){ return this.next; } @Override public String toString() { return "[" + s + "] => "; } } Of course, my HashTable has an array of Element to stock the data: public class CustomHashTable { private Element[] data; Here is my problem: For example I want to implement a method that adds an element AT THE END of the linked List (I know it would have been simpler and more efficient to insert the element at the beginning of the list, but again, this is only for training purposes). How do I do that without pointer? Here is my code (which could work if e was a pointer...): public void add(String s){ int index = hash(s) % data.length; System.out.println("Adding at index: " + index); Element e = this.data[index]; while(e != null){ e = e.getNext(); } e = new Element(s); } Thanks!

    Read the article

  • Display problem after deletion in linked list in C

    - by LuckySlevin
    Hi, actually this was another problem but it changed so I decided to open a new question. My code is typedef struct inner_list { int count; char word[100]; inner_list*next; } inner_list; typedef struct outer_list { char word [100]; inner_list * head; int count; outer_list * next; } outer_list; void delnode(outer_list **head,char num[100])//thanks to both Nir Levy and Jeremy P. { outer_list *temp, *m; m=temp=*head; /*FIX #1*/ while(temp!=NULL) { if(strcmp(temp->word,num)==0) { if(temp==*head) { delinner(temp->head); /* FIX#2 */ *head=temp->next; free(temp); return; } else { delinner(temp->head); /* FIX#2 */ m->next=temp->next; free(temp); return; } } else { m=temp; temp= temp->next; } } printf(" ELEMENT %s NOT FOUND ", num); } void delinner(inner_list *head) { /* FIX#2 */ inner_list *temp; temp=head; while(temp!=NULL) { head=temp->next; free(temp); temp=head; } } void delnode2(outer_list *up,inner_list **head,char num[100]) { inner_list *temp2,*temp, *m; outer_list *p; p = up; while(p!=NULL){m=temp=temp2=p->head; while(temp!=NULL) { if(strcmp(temp->word,num)==0) { if(temp==(*head)) { *head=temp->next; free(temp); return; } else { m->next=temp->next; free(temp); return; } } else { m=temp; temp= temp->next; } } p=p->next; } printf(" ELEMENT %s NOT FOUND ", num); } void print_node(outer_list *parent_node) { while(parent_node!=NULL){ printf("%s\t%d\t", parent_node->word, parent_node->count); inner_list *child_node = parent_node->head; printf("list: "); if(child_node ==NULL){printf("BUARADA");} while (child_node != NULL) { printf("%s-%d", child_node->word,child_node->count); child_node = child_node->next; if (child_node != NULL) { printf("->"); } } printf("\n"); parent_node = parent_node->next; } } While deleting an element from outer list I am also trying the delete the same element from inner_list too. For example: - Let's say aaa is an element of outer_list linked list and let's point it with outer_list *p - This aaa can also be in an inner_list linked list too. (it can be in p-head or another innerlist.) Now, the tricky part again. I tried to apply the same rules with outer_list deletion but whenever i delete the head element of inner_list it gives an error. Where is the wrong thing in print_node or delnode2?

    Read the article

  • How to remove Reply List option in Thunderbird 3?

    - by Joe Casadonte
    I receive email as part of a mailing list that also CC's other people. T-Bird defaults the toolbar button to Reply List instead of Reply All, which strips away the CC's. That's bad, because they're not on the list. Is there a way I can stop T-Bird from presenting Reply List as an option, or at least make Reply All the default? Thanks!

    Read the article

  • Handle Union of List in C# with duplicates

    - by user320587
    Hi, I am trying to understand how to handle union or merge of two lists that can have duplicates. For example, List1 has { A, B, C} and List2 has { B, C, D }. I tried to use the Union operation and got a new list with values (A, B, C, D}. However, I need the B & C values from the second list, not first one. Is there a way to specify the union method, which duplicate value to use. The code I am using now is var newList = List1.Union<Object>(List2).ToList(); Thanks for any help. Javid

    Read the article

  • Probability algorithm: Finding probable correct item in a list (e.g John, John, Jon)

    - by Andrew White
    Hi, Take for example the list (L): John, John, John, John, Jon We are to presume one item is to be correct (e.g. John in this case), and give a probability it is correct. First (and good!) attempt: MostFrequentItem(L).Count / L.Count (e.g. 4/5 or 80% likelihood) But consider the cases: John, John, Jon, Jonny John, John, Jon, Jon I want to consider the likelihood of the correct item being John to be higher in the first list! I know I have to count the SecondMostFrequent Item and compare them. Any ideas? This is really busting my brain! Thx, Andrew

    Read the article

  • Python: Inheritance of a class attribute (list)

    - by Sano98
    Hi everyone, inheriting a class attribute from a super class and later changing the value for the subclass works fine: class Unit(object): value = 10 class Archer(Unit): pass print Unit.value print Archer.value Archer.value = 5 print Unit.value print Archer.value leads to the output: 10 10 10 5 which is just fine: Archer inherits the value from Unit, but when I change Archer's value, Unit's value remains untouched. Now, if the inherited value is a list, the shallow copy effect strikes and the value of the superclass is also affected: class Unit(object): listvalue = [10] class Archer(Unit): pass print Unit.listvalue print Archer.listvalue Archer.listvalue[0] = 5 print Unit.listvalue print Archer.listvalue Output: 10 10 5 5 Is there a way to "deep copy" a list when inheriting it from the super class? Many thanks Sano

    Read the article

  • Bind list from FormView to model in ASP.net webforms

    - by Monty
    For a large fillin form I use the asp.net FormView for the magic databinding to my model. In this model I've a property called Rides (shown below), which exposes a list, which I obviously not want to be replaced entirely. So I made it readonly. However, this way I can't use the databinding features anymore. Is there a common solution for this problem? public IList<Ride> Rides { get { if (this._rides == null) { this._rides = new List<Ride>(); } return this._rides; } }

    Read the article

  • ie8 playing funny with list-style-position: inside

    - by Lee
    Ok, So problem here... when using list-style-position:inside in IE8 the first like is indented but every line after that is not. So the new lines appear under the bullet. This is fine, but when I use a list with that css applied with an a tag within the li then the text automatically gets pushed to the second line, and the first line is empty. When I remove the a tag from the li then it jumps back up. Any idea on why this might be or is this a bug in the ie8 world or do I just need to double check my css? Any insights would be much appreciated.

    Read the article

  • C++ classes & linked list: adding & counting items

    - by user342289
    I need to make a linked list with classes. Each list will store two values: a URI and IP. After doing all the adding, I need to be able count the total number of items in the linked list. I have tried the following code but it doesn't compile. Any suggestions please? #include <iostream> #include <cstdlib> #include <string> using namespace std; class ip_uri_store { protected: string ip; string uri; ip_uri_store *next; public: ip_uri_store(string huri, string hip); void additem(string auri, string aip); void deleteitem(string duri); void findbyuri(string furi); void findbyip(string fip); int totalitems(); }; ip_uri_store *head = NULL; ip_uri_store *curr = NULL; void ip_uri_store::additem(string auri, string aip) { curr = head; while (curr->next != NULL) { curr = curr->next; } curr->uri = auri; curr->next = new ip_uri_store; curr->ip = aip; curr->next = new ip_uri_store; curr = curr->next; curr = head; } int ip_uri_store::totalitems() { int i = 0; curr = head; while (curr->next != NULL) { i += 1; curr = curr->next; } return i; } int main(int argc, char *argv[]) { if (argc == 1) { cout << "123456, [email protected], Gordon Brown" << endl; return (0); } head = new ip_uri_store; curr = head; int i; for (i = 1; i < argc; i++) { if (argv[i][0] == 'A') //add item { ip_uri_store.additem(argv[i + 1], argv[i + 2]); i += 2; } else if (argv[i][0] == 'N') //print total tiems { cout << ip_uri_store.totalitems() << endl; } else { cout << "command error\n"; return 0; } } return (0); }

    Read the article

  • C# generic list <T> how to get the type of T?

    - by Daok
    Hello, Let say I have a List< T > abc = new List< T >; inside a class public class MyClass<T>//.... Later, when I initialize the class the T because MyTypeObject1. So I have a generic list of List< MyTypeObject1 >. I would like to know, what type of object the list of my class contain. Example, the list called abc contain what type of object? I cannot do abc[0].GetType(); because the list might contain 0 element. How can I do it?

    Read the article

  • Insert element into a tree from a list in Standard ML

    - by vichet
    I have just started to learn SML on my own and get stuck with a question from the tutorial. Let say I have: tree data type datatype node of (tree*int*tree) | null insert function fun insert (newItem, null) = node (null, newItem, null) | insert (newItem, node (left, oldItem, right)) = if (newItem <= oldItem) then node (insert(newItem,left),oldItem, right) else node (left, oldItem, insert(newItem, right) an integer list val intList = [19,23,21,100,2]; my question is how can I add write a function to loop through each element in the list and add to a tree? Your answer is really appreciated.

    Read the article

  • Erlang list comprehension, traversing two lists and excluding values

    - by ErJab
    I need to generate a set of coordinates in Erlang. Given one coordinate, say (x,y) I need to generate (x-1, y-1), (x-1, y), (x-1, y+1), (x, y-1), (x, y+1), (x+1, y-1), (x+1, y), (x+1, y+1). Basically all surrounding coordinates EXCEPT the middle coordinate (x,y). To generate all the nine coordinates, I do this currently: [{X,Y} || X<-lists:seq(X-1,X+1), Y<-lists:seq(Y-1,Y+1)] But this generates all the values, including (X,Y). How do I exclude (X,Y) from the list using filters in the list comprehension?

    Read the article

  • n elements in singly linked list

    - by Codenotguru
    The following function is trying to find the nth to last element of a singly linked list. for ex: if the elements are 8-10-5-7-2-1-5-4-10-10 then the result is 7th to last node is 7. Can anybody help me on how this code is working or is there a better and simpler approach? LinkedListNode nthToLast(LinkedListNode head, int n) { if (head == null || n < 1) { return null; } LinkedListNode p1 = head; LinkedListNode p2 = head; for (int j = 0; j < n - 1; ++j) { // skip n-1 steps ahead if (p2 == null) { return null; // not found since list size < n } p2 = p2.next; } while (p2.next != null) { p1 = p1.next; p2 = p2.next; } return p1; }

    Read the article

  • issue in list of dict

    - by gaggina
    class MyOwnClass: # list who contains the queries queries = [] # a template dict template_query = {} template_query['name'] = 'mat' template_query['age'] = '12' obj = MyOwnClass() query = obj.template_query query['name'] = 'sam' query['age'] = '23' obj.queries.append(query) query2 = obj.template_query query2['name'] = 'dj' query2['age'] = '19' obj.queries.append(query2) print obj.queries It gives me [{'age': '19', 'name': 'dj'}, {'age': '19', 'name': 'dj'}] while I expect to have [{'age': '23' , 'name': 'sam'}, {'age': '19', 'name': 'dj'}] I thought to use a template for this list because I'm gonna to use it very often and there are some default variable who does not need to be changed. Why does doing it the template_query itself changes? I'm new to python and I'm getting pretty confused.

    Read the article

  • Algorithm to generate a list of unique combinations based on a list of numbers

    - by ross
    I would like to efficiently generate a unique list of combinations of numbers based on a starting list of numbers. example start list = [1,2,3,4,5] but the algorithm should work for [1,2,3...n] result = [1],[2],[3],[4],[5] [1,2],[1,3],[1,4],[1,5] [1,2,3],[1,2,4],[1,2,5] [1,3,4],[1,3,5],[1,4,5] [2,3],[2,4],[2,5] [2,3,4],[2,3,5] [3,4],[3,5] [3,4,5] [4,5] Note. I don't want duplicate combinations, although I could live with them, eg in the above example I don't really need the combination [1,3,2] because it already present as [1,2,3]

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >