Search Results

Search found 31721 results on 1269 pages for 'adjacency list'.

Page 86/1269 | < Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >

  • Django Template - Convert python list into a javascript object

    - by amcashcow
    I am working on a django / python website I have a page where I want to display a table of search results The list of results is passed in to the template as normal I also want to make this list of objects accessible to the javascript code My first solution was just create another view that returned json format. But each page load required calling the query twice. So then I tried only downloading the data using the json view and printing the table using javascript. but this is also not desirable as now the presentation layer is mixed into the javascript code. is there a way to create a javascript object from the python list as the page is rendered?

    Read the article

  • Determining whether a class implements a generic list in a T4 template

    - by James Hollingworth
    I'm writing a T4 template which loads some classes from an assembly, does some analysis of the classes and then generates some code. One particular bit of analysis I need to do is to determine whether the class implements a generic list. I can do this pretty simply in C#, e.g. public class Foo : List<string> { } var t = typeof(Foo); if (t.BaseType != null && t.BaseType.IsGenericType && t.BaseType.GetGenericTypeDefinition() == typeof(List<>))) Console.WriteLine("Win"); However T4 templates use the FXCop introspection engine and so you do not have access to the .net reflection API. I've spent the past couple of hours in Reflector but still can't figure it out. Does anyone have any clues about how to do this?

    Read the article

  • Add list type to association

    - by teucer
    Hi All, I am using the eUML2 (Free version) plugin to draw a UML class diagram. Now, let's assume I have a class Person and a class Car. I want the class Person to have a member cars which is a List<Car>, i.e. private List<Car> cars = null. My question is how do I include this information in the class diagram? To be more precise, how do I include the type information for the List in the eUML2 association? Regards

    Read the article

  • saving value selected in a list when submit button is cliked

    - by kawtousse
    Hi everyone, In my JSP I have a dropdownlist and a submit button when clicking the submit button I loose the value already selected in my list. I am using the jstl because i need to construct other table corresponding the value selected in my list.For that I must call a submit button but the problem; it reset the value selected I want to know if there is a way to save the value selected in my list even I click a submit button. I work with JSP and eclipse environment. Think you for your help.

    Read the article

  • Purpose of front() and back() in assigning values in a Queue? (C++)

    - by kevin
    I have declared: queue<int, list<int> > Q After a series of calls: Q.push(37); Q.pop(); Q.push(19); Q.push(3); Q.push(13); Q.front(); Q.push(22); Q.push(8); Q.back(); I get: 19-3-13-22-8-NULL What I don't get is what the calls to Q.front() and Q.back() do. From what I understand, they return a reference to the first or last elements respectively, but I dont see how my list would be any different had those calls not been made. Do they have any effect? Sorry if this seems trivial, but I'm trying to figure out of those calls have a purpose, or of my professor is just trying to screw with me.

    Read the article

  • Programmatically determine the relative "popularities" of a list of items (books, songs, movies, etc

    - by Horace Loeb
    Given a list of (say) songs, what's the best way to determine their relative "popularity"? My first thought is to use Google Trends. This list of songs: Subterranean Homesick Blues Empire State of Mind California Gurls produces the following Google Trends report: (to find out what's popular now, I restricted the report to the last 30 days) Empire State of Mind is marginally more popular than California Gurls, and Subterranean Homesick Blues is far less popular than either. So this works pretty well, but what happens when your list is 100 or 1000 songs long? Google Trends only allows you to compare 5 terms at once, so absent a huge round-robin, what's the right approach? Another option is to just do a Google Search for each song and see which has the most results, but this doesn't really measure the same thing

    Read the article

  • Erlang - list comprehensions - populating records

    - by tbikeev
    I have a simple record structure consisting of a header (H) and a list of the data lines (D) 1:N. All header lines must start with a digit. All data lines have a leading whitespace. There also might be some empty lines (E) in between that must be ignored. L = [H, D, D, E, H, D, E, H, D, D, D]. I would like to create a list of records: -record(posting,{header,data}). using list comprehension. Whats the best way to do it?

    Read the article

  • flex accessing children of a list component

    - by pfunc
    when I try to loop through the children of a List component that has buttons in it, I can't seem to access those children. I try for(var btnNum:Number = 0; btnNum < myList.numChildren; btnNum++) { trace(myList.getChildAt(btnNum); } but it is giving some other instance, not the button instances. and the weeklist <mx:List id="myList" dataProvider="{_data.mappoints.week.@number}" > <mx:itemRenderer > <mx:Component> <mx:Button buttonMode="true" toggle="true" alpha="1" width="116" height="35" label="WEEK {data}" > </mx:Button> </mx:Component> </mx:itemRenderer> </mx:List>

    Read the article

  • List files starting with a specific name using java

    - by user3610075
    i want to list files starting with a name like "Report" from a folder. i found this in google to list all files but i don't how to list file starting with a name. Thank you File directory = new File("C:\\Users\\kiki\\Downloads"); File[] files = directory.listFiles(); for (int index = 0; index < files.length; index++) { //Print out the name of files in the directory System.out.println(files[index].toString()); }

    Read the article

  • A better way of representing File Attachment into a list(c#3.0)

    - by Newbie
    I have written List<Attachment> lstAttachment = new List<Attachment>(); //Check if any error file is present in which case it needs to be send if (new FileInfo(Path.Combine(errorFolder, errorFileName)).Exists) { Attachment unprocessedFile = new Attachment(Path.Combine(errorFolder, errorFileName)); lstAttachment.Add(unprocessedFile); } //Check if any processed file is present in which case it needs to be send if (new FileInfo(Path.Combine(outputFolder, outputFileName)).Exists) { Attachment processedFile = new Attachment(Path.Combine(outputFolder, outputFileName)); lstAttachment.Add(processedFile); } Working fine and is giving the expected output. Basically I am attaching the file to the list based on whether the file is present or not. I am looking for any other elegant solution than the one I have written. Reason: Want to learn differnt ways of representing the same program. I am using C#3.0 Thanks.

    Read the article

  • [Python] Best strategy for dealing with incomplete lines of data from a file.

    - by adoran
    I use the following block of code to read lines out of a file 'f' into a nested list: for data in f: clean_data = data.rstrip() data = clean_data.split('\t') t += [data[0]] strmat += [data[1:]] Sometimes, however, the data is incomplete and a row may look like this: ['955.159', '62.8168', '', '', '', '', '', '', '', '', '', '', '', '', '', '29', '30', '0', '0'] It puts a spanner in the works because I would like Python to implicitly cast my list as floats but the empty fields '' cause it to be cast as an array of strings (dtype: s12). I could start a second 'if' statement and convert all empty fields into NULL (since 0 is wrong in this instance) but I was unsure whether this was best. Is this the best strategy of dealing with incomplete data? Should I edit the stream or do it post-hoc?

    Read the article

  • Non-empty list with null elements returned from Hibernate query

    - by John
    Hi, I'm new to hibernate so not sure if this is an expected behaviour, anyway: Session session = (Session)entityManager.getDelegate(); Criteria criteria = session.createCriteria(myRequest.class); criteria.add(Restrictions.eq("username", username)); criteria.setProjection(Projections.max("accesscount")); List<myRequest> results = criteria.list(); The returned results is a non-empty list with a single null element. I can't think of any reason why it should behave this way, any idea if this is the expected behaviour or have I done something wrong? System is on hibernate/Syabse. Thanks.

    Read the article

  • How to write a list to a text file in the correct format

    - by lia1000
    I've got this piece of code that I want to write the output to a text file but with the correct format i.e. no brackets, single quotes so it appears as a formatted list. This is the code: file = open("env5.txt", "w"); for key in os.environ.keys(): env = os.environ[key]; key1 = key; list = str([key, env]).replace("'","").replace('[]', ''); list2 = list[1:-1]; print(list2); file.writelines(list2); file.close(); This is the original code: for key in os.environ.keys(): print(key, os.environ[key]); Many thanks

    Read the article

  • Python . How to get rid of '\r' in string?

    - by draconisthe0ry
    I have an excel file that I converted to a text file with a list of numbers. test = 'filelocation.txt' in_file = open(test,'r') for line in in_file: print line 1.026106236 1.660274766 2.686381002 4.346655769 7.033036771 1.137969254 a = [] for line in in_file: a.append(line) print a '1.026106236\r1.660274766\r2.686381002\r4.346655769\r7.033036771\r1.137969254' I wanted to assign each value (in each line) to an individual element in the list. Instead it is creating one element separated by \r . i'm not sure what \r is but why is putting these into the code ? I think I know a way to get rid of the \r from the string but i want to fix the problem from the source

    Read the article

  • depth first search graph by using linked list

    - by programmerwannabe
    im using mac book and i cannot read the text file using this code. moreover, can you guys please add function(graph is connected?, and is this graph tree?) inputA.txt consist 1 2 1 6 1 5 2 3 2 6 3 4 3 6 4 5 4 6 5 6 #include <stdio.h> #include <memory.h> #include <stdlib.h> #define MAX 10 #define TRUE 1 #define FALSE 0 typedef struct Graph{ int vertex; struct Graph* link; } g_node; typedef struct graphType{ int x; int visited[MAX]; g_node* adjList_H[MAX]; } graphType; typedef struct stack{ int data; struct stack* link; } s_node; s_node* top; void push(int item){ s_node* n=(s_node*)malloc(sizeof(s_node)); n->data = item; n->link = top; top = n; } int pop(){ int item; s_node* n=top; if(top == NULL){ puts("\nstack is empty!\n"); return 0; } else { item = n-> data; top = n->link; free(n); return item; } } void createGraph(graphType* g){ int v; g->x = 1; for(v=1 ; v < MAX ; v++){ g -> visited[v] = FALSE; g -> adjList_H[v] = NULL; } } void insertVertex(graphType* g, int v){ if(((g->x)) > MAX){ puts("\n it has been overed the number of vertex\n"); return ; } g -> x++; } void insertEdge(graphType* g, int u, int v){ g_node* node; if(u >= g -> x || v >= g -> x){ puts("\n no vertex in the graph\n"); return ; } node = (g_node*)malloc(sizeof(g_node)); node -> vertex = v; node -> link = g -> adjList_H[u]; g-> adjList_H[u] = node; } void print_adjList(graphType* g){ int i; g_node *p; for(i=1 ; i<g -> x ; i++){ printf("\n\t\t vertex %d adjacency list ", i); p = g -> adjList_H[i]; while(p){ printf("-> %d", p-> vertex); p = p-> link; } } } void DFS_adjList(graphType* g, int v) { g_node* w; top = NULL; push(v); g->visited[v] = TRUE; printf(" %d", v); while(top != NULL){ w=g->adjList_H[v]; while(w){ if (!g->visited[w->vertex]){ push(w->vertex); g->visited[w->vertex] = TRUE; printf(" %d", w->vertex); v = w->vertex; w=g->adjList_H[v]; } else w= w->link; } v = pop(); } } int main (int argc, const char * argv[]) { FILE *fp; char mychar; char arr[][2]={0, }; int j, k; int i; graphType *G9; G9 = (graphType*)malloc(sizeof(graphType)); createGraph(G9); for(i=1; i<7 ; i++) insertVertex(G9, i); fp = fopen("inputD.txt", "r"); for(j = 0 ; j< 10 ; j++){ for(k = 0 ; k < 2 ; k++){ mychar = fgetc(fp); if(mychar = EOF){ j=10; break; } else if(mychar == ' ') continue; else if(mychar <= '9' || mychar >= '1'){ arr[j][k] = mychar; printf("%d%d", arr[i][k]); } } } insertEdge(G9, 1, 2); insertEdge(G9, 1, 6); insertEdge(G9, 1, 5); insertEdge(G9, 2, 3); insertEdge(G9, 2, 6); insertEdge(G9, 3, 4); insertEdge(G9, 3, 6); insertEdge(G9, 4, 5); insertEdge(G9, 4, 6); insertEdge(G9, 5, 6); insertEdge(G9, 6, 5); insertEdge(G9, 6, 4); insertEdge(G9, 5, 4); insertEdge(G9, 6, 3); insertEdge(G9, 4, 3); insertEdge(G9, 6, 2); insertEdge(G9, 3, 2); insertEdge(G9, 5, 1); insertEdge(G9, 6, 1); insertEdge(G9, 2, 1); printf("\n graph adjacency list "); print_adjList(G9); printf("\n \n//////////////////////////////////////////////\n\n depth fist search >> "); DFS_adjList(G9, 1); return 0; }

    Read the article

  • Why is my Network Connections list empty?

    - by DealerNextDoor
    I'm sure this question has been asked before, but none of the links I have found have worked. I've been trying to find fixes for the past couple of weeks. This all started a few days after I got my router. At first, I thought it was just something that would fix it self. But as usual, it never does. I am trying to update my router's wireless card to try and fix this problem, but I need to get the card's information to update it on the HP website. And since my Network Connections list is empty, I can't get any information about it. So to get around this, I tried to go to 'Manage Wireless Networks', and when I tried to get the properties from there, I get this error: Windows has encounter an error saving the wireless profile. Specific Error: The data is invalid. So, what all can I do to try and fix this? Any help will be appreciated. EDIT: Sorry, forgot to put router info. Router Model: WNR1000v2-V2 Router Maker: NETGEAR Router Firmware Version: V1.0.0.12NA The router is up-to-date on all updates.

    Read the article

  • error creating MS Exchange distribution list: Active directory response: 00000005: SecErr: DSID-031521D0

    - by BabakBani
    We've migrated a client from google apps to an MS Exchange 2010 SP2 on-premise setup. The setup /prepareAD went well, and the software was installed with the Administrator account. We've used the Exchange Management Console to setup mailboxes and had to google up the appropriate workarounds such as going into each users Advanced Security Settings and selecting "include inheritable permissions from this object's parents", and changing their logon-to from specific machines to "all computers" so that they can connect to Outlook Web Access, and in turn so their Outlook 2007-2010 clients can connect to Exchange. Sending and receiving emails are working well. Now that all this is in place, we can create Dynamic Distrubution Lists with no problem, but as soon as we try and create a DISTRIBUTION LIST, either in the EMC or the Exchange PowerShell, we get an error. As the error message in the powershell is more verbose, I include this if anyone can suggest how we remedy this: [PS] C:\Windows\system32new-DistributionGroup -Name 'projects' -SamAccountName 'projects' -Alias 'projects' Active Directory operation failed on DC.cppe.local. This error is not retriable. Additional information: Access is denied. Active directory response: 00000005: SecErr: DSID-031521D0, problem 4003 (INSUFF_ACCESS_RIGHTS), data 0 + CategoryInfo : NotSpecified: (0:Int32) [New-DistributionGroup], ADOperationException + FullyQualifiedErrorId : 1EA5CD3E,Microsoft.Exchange.Management.RecipientTasks.NewDistributionGroup

    Read the article

  • Windows XP laptop doesn't appear in WSUS All computers list

    - by George
    I have this one laptop that doesn't appear in WSUS all computers list. We have about 23-25 PCs/laptops/servers in the network, all, but one are listed in WSUS. This is what I have done so far: 1) Changing Updates on local PC: Go to your Windows XP client and start a new Microsoft Management Console (MMC). At Start, Run, type MMC. Use Ctrl+M to add a new snap-in. Click Add, and then add the Group Policy Object Editor for the Local Computer. Click Close, and then click OK. Expand the Local Computer Policy. Under Computer Configuration, go to Administrative Templates, Windows Components, Windows Update. In the right-hand pane, double-click Specify intranet Microsoft update service location. Configure the settings to reflect my WSUS server. Click OK and then close the MMC without saving it. executed wuauclt.exe /detectnow 2) Edited registry key to be pushed to the PCs using GPO [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate] "WUServer"=http://wsusserver "TargetGroupEnabled"=dword:00000001 "TargetGroup"="WINXP" "WUStatusServer"=http://wsuswerver 3) executed wuauclt /resetauthorization /detectnow 4)Synchronised and refreshed the group I am running out of ideas here. The client is running Windows XP pro, WSUS version is 3.0 and is running on Windows 2008 R2 64-bit. Please, help! Thanks! EDIT 13.IX.2012 @ 15.40 I should have also mentioned that we do have a Windows Update GPO for workstations group and that laptop is a part of that group.

    Read the article

  • Typical outbound port list for guest access?

    - by Steve
    I manage a weekly rental house that includes wireless Internet access. I've allowed all outbound ports on my router but my ISP has disabled my Internet access twice now because guests have downloaded (or served up) copyrighted content. So I'd like to institute some port filtering to discourage p2p sharing (see disclaimer below). But I don't want to inconvenience the 99.9% of folks who keep things above-board. My question is, what outbound ports are typically open for rental/hotel wireless Internet access, or where can I find such a list? TCP 80,443,25,110 at a minimum. Though my own email service uses 995 and 465 for SSL, some may use IMAP, I personally use SSH and FTP, so I'll open those. Roughly I figure I need to open access to privileged ports, and close 1024 & above. Is there a whitelist I should institute for commonly used high ports? And does it make sense to block UDP 1024 ? Disclaimer: I realize anyone replying to this message could circumvent the port filtering and share content to their heart's content. I do not need comprehensive p2p blocking, which requires more than a port whitelist. Anyone staying at the house shoulders the responsibility for their Internet use, per the rental contract. Also anyone savvy enough to circumvent the port filters would hopefully be savvy enough to use some sort of peer blocking, thereby preventing the ISP from taking down the service.

    Read the article

  • Blank list of windows services

    - by Joe
    Recently when I open windows services (always as administrator) I get a blank list of services: When I try and click on one of the empty lines I get this "Script Error" message: This happens over and over again, after several times I restarted my computer. I can't pinpoint exactly when this started happening or if I made any specific changes to my computer at that time. Someone told my to try running scf /scannow as administrator, but when I try to do that the scan stops at 34% and I get the message: "Windows Resource Protection could not perform the requested operation." I am running Windows 7 Enterprise 64 bit, and I would really like to avoid reinstalling windows. Does anyone know how to fix this? Edit - Here is another attempt I made and some more information that might help: Following WhoIsRich's suggestion, I tried the command sfc /scannow /offbootdir=c:\ /offwindir=c:\windows. This gave the error message "The arguments passed to sfc are invalid. The offline windows directory specified points to the online system", and then I realized this command is meant to be run after booting from another system. Since I don't have my windows installation disk right now, I used my own system to create a recovery disk, and then restarted my computer and used the recovery disk to boot. I then ran the above command, and I got the following message: "Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.log". I then restarted my computer and let it boot up normally. The problem with windows services persists, and the CBS.log file is a long log file with many entries, and I don't know if there is useful information in it, and if there is, how to find it.

    Read the article

  • zsh : How to list directory content with tab?

    - by Philippe CM
    I just switched from BASH to ZSH and thing are pretty good, but: when I start typing cd /usr/share/s and hit TAB, this is what I get : $ cd /usr/share/sane/ sane/ skype/ ssl-cert/ screen/ smplayer/ strigi/ seed-gtk3/ snmp/ synaptic/ sgml/ software-properties/ system-config-printer/ sgml-base/ soprano/ sysv-rc/ sgml-data/ sounds/ simple-scan/ splashy/ And this is ok. If I then hit TAB again, I get $ cd /usr/share/screen/, the next candidate, witch is also OK. (BTW, how do I cycle back to the previous candidate? Sorry, on to my question) Now what if I want to see the contents of /usr/share/screen/ now ? You now, BASH-style? The cursor is at the end of the line, will I have to ctrl-a (or home), then del del (to erase cd) then ls then ENTER? That seems like a lot of typing. (And it - possibly unnecessarily - enters the command in the history) Would not there be a key (maybe modifier-TAB? but the obvious candidates are already taken by the desktop... I digress) that would tell zsh to stop cycling through /usr/share/ and instead, just list the content /usr/share/screen/ ?

    Read the article

  • Business rule validation of hierarchical list of objects ASP.NET MVC

    - by SergeanT
    I have a list of objects that are organized in a tree using a Depth property: public class Quota { [Range(0, int.MaxValue, ErrorMessage = "Please enter an amount above zero.")] public int Amount { get; set; } public int Depth { get; set; } [Required] [RegularExpression("^[a-zA-Z]+$")] public string Origin { get; set; } // ... another properties with validation attributes } For data example (amount - origin) 100 originA 200 originB 50 originC 150 originD the model data looks like: IList<Quota> model = new List<Quota>(); model.Add(new Quota{ Amount = 100, Depth = 0, Origin = "originA"); model.Add(new Quota{ Amount = 200, Depth = 0, Origin = "originB"); model.Add(new Quota{ Amount = 50, Depth = 1, Origin = "originC"); model.Add(new Quota{ Amount = 150, Depth = 1, Orinig = "originD"); Editing of the list Then I use Editing a variable length list, ASP.NET MVC 2-style to raise editing of the list. Controller actions QuotaController.cs: public class QuotaController : Controller { // // GET: /Quota/EditList public ActionResult EditList() { IList<Quota> model = // ... assigments as in example above; return View(viewModel); } // // POST: /Quota/EditList [HttpPost] public ActionResult EditList(IList<Quota> quotas) { if (ModelState.IsValid) { // ... save logic return RedirectToAction("Details"); } return View(quotas); // Redisplay the form with errors } // ... other controller actions } View EditList.aspx: <%@ Page Title="" Language="C#" ... Inherits="System.Web.Mvc.ViewPage<IList<Quota>>" %> ... <h2>Edit Quotas</h2> <%=Html.ValidationSummary("Fix errors:") %> <% using (Html.BeginForm()) { foreach (var quota in Model) { Html.RenderPartial("QuotaEditorRow", quota); } %> <% } %> ... Partial View QuotaEditorRow.ascx: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Quota>" %> <div class="quotas" style="margin-left: <%=Model.Depth*45 %>px"> <% using (Html.BeginCollectionItem("Quotas")) { %> <%=Html.HiddenFor(m=>m.Id) %> <%=Html.HiddenFor(m=>m.Depth) %> <%=Html.TextBoxFor(m=>m.Amount, new {@class = "number", size = 5})%> <%=Html.ValidationMessageFor(m=>m.Amount) %> Origin: <%=Html.TextBoxFor(m=>m.Origin)%> <%=Html.ValidationMessageFor(m=>m.Origin) %> ... <% } %> </div> Business rule validation How do I implement validation of business rule: Amount of quota and sum of amounts of nested quotas should equal (e.a. 200 = 50 + 150 in example)? I want to appropriate inputs Html.TextBoxFor(m=>m.Amount) be highlighted red if the rule is broken for it. In example if user enters not 200, but 201 - it should be red on submit. Using sever validation only. Thanks a lot for any advise.

    Read the article

  • How to prevent window list "confusion" when detaching eclipse views?

    - by amotzg
    I'm detaching eclipse views to float on my other screen in order to get more coding space on the first screen. When doing that, the detached windows appear in ubuntu's window list applet with the eclipse icon but with no title. Then, when pushing the main eclipse button on the window list, one of the detached views will get to front but not the main eclipse window. When using Alt+tab I can also see the extra eclipse icons but choosing the correct one for the main window works and make it the active window while also showing all detached childs. Other applications behave as expected, e.g. gimp floating panels don't show on the windows list and this is also the case with SlickEdit, Firefox child windows all show on window list but gets the focus correctly, etc. I can see the the workspace switcher show my two screens but in 'Monitor preferences' I see my two screens as one big screen. I'm working with ubuntu 10.04.4 under a VMware Workstation 7.1.3 build-324285. 'uname -a' output: Linux ubuntu 2.6.32-40-generic #87-Ubuntu SMP Tue Mar 6 00:56:56 UTC 2012 x86_64 GNU/Linux The desktop screen shot with the problem, ununtu's version, and Monitor preferences. How can I solve it and make only the main window show in window list or at least get activated when pushing it's button on the window list?

    Read the article

  • Is it a good practice to create a list of definitions for all symbols and words in a programming language?

    - by MrDaniel
    After arriving at this point in Learning Python The Hard Way I am wondering if this is a good practice to create a list of symbols and define what they do as noted in bold below, for every programming language. This seems reasonable, and might be very useful to have when jumping between programming languages? Is this something that programmers do or is it just a waste of effort? Exercise 22: What Do You Know So Far? There won't be any code in this exercise or the next one, so there's no WYSS or Extra Credit either. In fact, this exercise is like one giant Extra Credit. I'm going to have you do a form of review what you have learned so far. First, go back through every exercise you have done so far and write down every word and symbol (another name for 'character') that you have used. Make sure your list of symbols is complete. Next to each word or symbol, write its name and what it does. If you can't find a name for a symbol in this book, then look for it online. If you do not know what a word or symbol does, then go read about it again and try using it in some code. You may run into a few things you just can't find out or know, so just keep those on the list and be ready to look them up when you find them. Once you have your list, spend a few days rewriting the list and double checking that it's correct. This may get boring but push through and really nail it down. Once you have memorized the list and what they do, then you should step it up by writing out tables of symbols, their names, and what they do from memory. When you hit some you can't recall from memory, go back and memorize them again.

    Read the article

  • Using LINQ in generic collections

    - by Hugo S Ferreira
    Hi, Please consider the following snippet from an implementation of the Interpreter pattern: public override object Execute(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable<string>; return (list != null) ? list.FirstOrDefault() : null; } What about if I want to use the same function for integers? public override object Execute(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable<string>; if (list != null) return list.FirstOrDefault(); var list = ctx as IEnumerable<int>; return (list != null) ? list.FirstOrDefault() : null; } What I wanted was something like: public override object Execute(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable; return (list != null) ? list.FirstOrDefault() : null; } But Linq doesn't act on IEnumerables. Instead, to get to this solution, I would be forced to write something like: public override object Execute(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable; if (list != null) foreach(var i in list) { yield return i; return; } return null; } Or use a generic method: public override T Execute<T>(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable<T>; return (list != null) ? list.FirstOrDefault() : null; } Which would break the Interpreter pattern (as it was implemented in this system). Covariance would also fail (at least in C#3), though would it work, it would be the exact behavior I wanted: public override object Execute(Interpreter interpreter, object ctx) { var list = ctx as IEnumerable<object>; return (list != null) ? list.FirstOrDefault() : null; } So, my question is: what's the best way to achieve the intended behavior? Thanks :-)

    Read the article

< Previous Page | 82 83 84 85 86 87 88 89 90 91 92 93  | Next Page >