Search Results

Search found 1488 results on 60 pages for 'dan wray'.

Page 32/60 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • What's the right way to do mutable data structures (e.g., skip lists, splay trees) in F#?

    - by dan
    What's a good way to implement mutable data structures in F#? The reason I’m asking is because I want to go back and implement the data structures I learned about in the algorithms class I took this semester (skip lists, splay trees, fusion trees, y-fast tries, van Emde Boas trees, etc.), which was a pure theory course with no coding whatsoever, and I figure I might as well try to learn F# while I’m doing it. I know that I “should” use finger trees to get splay tree functionality in a functional language, and that I should do something with laziness to get skip-list functionality, etc. , but I want to get the basics nailed down before I try playing with purely functional implementations. There are lots of examples of how to do functional data structures in F#, but there isn’t much on how to do mutable data structures, so I started by fixing up the doubly linked list here into something that allows inserts and deletes anywhere. My plan is to turn this into a skip list, and then use a similar structure (discriminated union of a record) for the tree structures I want to implement. Before I start on something more substantial, is there a better way to do mutable structures like this in F#? Should I just use records and not bother with the discriminated union? Should I use a class instead? Is this question "not even wrong"? Should I be doing the mutable structures in C#, and not dip into F# until I want to compare them to their purely functional counterparts? And, if a DU of records is what I want, could I have written the code below better or more idiomatically? It seems like there's a lot of redundancy here, but I'm not sure how to get rid of it. module DoublyLinkedList = type 'a ll = | None | Node of 'a ll_node and 'a ll_node = { mutable Prev: 'a ll; Element : 'a ; mutable Next: 'a ll; } let insert x l = match l with | None -> Node({ Prev=None; Element=x; Next=None }) | Node(node) -> match node.Prev with | None -> let new_node = { Prev=None; Element=x; Next=Node(node)} node.Prev <- Node(new_node) Node(new_node) | Node(prev_node) -> let new_node = { Prev=node.Prev; Element=x; Next=Node(node)} node.Prev <- Node(new_node) prev_node.Next <- Node(new_node) Node(prev_node) let rec nth n l = match n, l with | _,None -> None | _,Node(node) when n > 0 -> nth (n-1) node.Next | _,Node(node) when n < 0 -> nth (n+1) node.Prev | _,Node(node) -> Node(node) //hopefully only when n = 0 :-) let rec printLinkedList head = match head with | None -> () | Node(x) -> let prev = match x.Prev with | None -> "-" | Node(y) -> y.Element.ToString() let cur = x.Element.ToString() let next = match x.Next with | None -> "-" | Node(y) -> y.Element.ToString() printfn "%s, <- %s -> %s" prev cur next printLinkedList x.Next

    Read the article

  • Facebook og:url ignored in favour of a Facebook hosted page about the og entity

    - by Dan
    I am trying to implement the Like button on my pages. Those pages represent the review page for a product. When a user Likes the page, it shows up in Facebook (not as a link, but as liking an entity), however when you click on the entity in Facebook it links through to a facebook.com hosted page representing the page. I want the user to be redirected to the og:url page? This happens for example when you Like an artist page on Grroveshar: http://grooveshark.com/#!/artist/Elbow/4795 I am clearly "doing it wrong". I am using the following markup to include the SDK. MYAPPID is included by the code generator Facebook provides so I assume it is required. <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=MYAPPID"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk'));</script> Then my code to render the Like button. <div class="fb-like" data-send="false" data-width="450" data-show-faces="true"></div> And finally my og tags: <meta property="og:title" content="My product" /> <meta property="og:type" content="product" /> <meta property="og:url" content="http://site.com/product_1/" /> <meta property="og:image" content="http://site.com/image1.jpg" /> <meta property="og:site_name" content="My-Site-Name.com" /> <meta property="fb:admins" content="MYFACEBOOKID" /> <meta property="fb:app_id" content="MYAPPID" /> Thanks!

    Read the article

  • aws-s3 can't find xml-simple, but in gem list

    - by Dan Donaldson
    I'm transitioning to heroku, and need to have AWS-s3 connections to deal with a variety of graphics. I've installed the aws-s3 gem, but one of its dependencies is not being found: xml-simple. My belief is that this is a standard part of RoR, and it is in the gem list. When I deploy to heroku, all is fine, but on my development server, it isn't being found when the code uses it to check the existence of a graphic. It works fine from the console, using s3sh. I'm not quite sure why this is -- what do I need to check? Using OS X 10.6, on a 64 bit machine -- can this be part of it?

    Read the article

  • Inheriting list item permissions via permissions on lookup field item

    - by Dan Sydner
    Say you have two lists in Sharepoint, let's call them "house" and "region". Each house is assigned to a region via a lookup field. List item permissions are set on regions. Now I want the users only to only see the houses which belong to the regions they have read access to. I reckon it should be relatively simple I see no easy way of doing this. Am I over looking something.

    Read the article

  • Return value from ajax call?

    - by Dan
    Hi, I'm making a basic ajax function in jquery which echoes the number of rows found in a MySQL Query. function checkEventIDClass(id) { var params = 'method=checkEventIDClash&table=test&id=' + id; $.ajax({ type: "POST", url: "ajax.php", data: params, success: function(result){ return result; } }); } Is it possible to use this returned value in another function? I have tried but only get undefined values. In this situation, it will be acceptable to use synchronous calls. Any advice appreciated. Thanks

    Read the article

  • How do you read system jobs in Dynamics CRM?

    - by Dan Crowther
    The CRM SDK says this is possible but the following code fails. Does anyone know why? var request = new RetrieveMultipleRequest(); var query = new QueryExpression(EntityName.asyncoperation.ToString()); query.ColumnSet = new AllColumns(); request.Query = query; var response = _connection.Execute(request); The error is: <error>\n <code>0x80040216</code> <description>An unexpected error occurred.</description> <type>Platform</type> </error> If I change the entity name to account, it works fine.

    Read the article

  • Is Fast Enumeration messing with my text output?

    - by Dan Ray
    Here I am iterating through an array of NSDictionary objects (inside the parsed JSON response of the EXCELLENT MapQuest directions API). I want to build up an HTML string to put into a UIWebView. My code says: for (NSDictionary *leg in legs ) { NSString *thisLeg = [NSString stringWithFormat:@"<br>%@ - %@", [leg valueForKey:@"narrative"], [leg valueForKey:@"distance"]]; NSLog(@"This leg's string is %@", thisLeg); [directionsOutput appendString:thisLeg]; } The content of directionsOutput (which is an NSMutableString) contains ALL the values for [leg valueForKey:@"narrative"], wrapped up in parens, followed by a hyphen, followed by all the parenthesized values for [leg valueForKey:@"distance"]. So I put in that NSLog call... and I get the same thing there! It appears that the for() is somehow batching up our output values as we iterate, and putting out the output only once. How do I make it not do this but instead do what I actually want, which is an iterative output as I iterate? Here's what NSLog gets. Yes, I know I need to figure out NSNumberFormatter. ;-) This leg's string is ( "Start out going NORTH on INFINITE LOOP.", "Turn LEFT to stay on INFINITE LOOP.", "Turn RIGHT onto N DE ANZA BLVD.", "Merge onto I-280 S toward SAN JOSE.", "Merge onto CA-87 S via EXIT 3A.", "Take the exit on the LEFT.", "Merge onto CA-85 S via EXIT 1A on the LEFT toward GILROY.", "Merge onto US-101 S via EXIT 1A on the LEFT toward LOS ANGELES.", "Take the CA-152 E/10TH ST exit, EXIT 356.", "Turn LEFT onto CA-152/E 10TH ST/PACHECO PASS HWY. Continue to follow CA-152/PACHECO PASS HWY.", "Turn SLIGHT RIGHT.", "Turn SLIGHT RIGHT onto PACHECO PASS HWY/CA-152 E. Continue to follow CA-152 E.", "Merge onto I-5 S toward LOS ANGELES.", "Take the CA-46 exit, EXIT 278, toward LOST HILLS/WASCO.", "Turn LEFT onto CA-46/PASO ROBLES HWY. Continue to follow CA-46.", "Merge onto CA-99 S toward BAKERSFIELD.", "Merge onto CA-58 E via EXIT 24 toward TEHACHAPI/MOJAVE.", "Merge onto I-15 N via the exit on the LEFT toward I-40/LAS VEGAS.", "Keep RIGHT to take I-40 E via EXIT 140A toward NEEDLES (Passing through ARIZONA, NEW MEXICO, TEXAS, OKLAHOMA, and ARKANSAS, then crossing into TENNESSEE).", "Merge onto I-40 E via EXIT 12C on the LEFT toward NASHVILLE (Crossing into NORTH CAROLINA).", "Merge onto I-40 BR E/US-421 S via EXIT 188 on the LEFT toward WINSTON-SALEM.", "Take the CLOVERDALE AVE exit, EXIT 4.", "Turn LEFT onto CLOVERDALE AVE SW.", "Turn SLIGHT LEFT onto N HAWTHORNE RD.", "Turn RIGHT onto W NORTHWEST BLVD.", "1047 W NORTHWEST BLVD is on the LEFT." ) - ( 0.0020000000949949026, 0.07800000160932541, 0.14000000059604645, 7.827000141143799, 5.0329999923706055, 0.15299999713897705, 5.050000190734863, 20.871000289916992, 0.3050000071525574, 2.802999973297119, 0.10199999809265137, 37.78000259399414, 124.50700378417969, 0.3970000147819519, 25.264001846313477, 20.475000381469727, 125.8580093383789, 4.538000106811523, 1693.0350341796875, 628.8970336914062, 3.7990000247955322, 0.19099999964237213, 0.4099999964237213, 0.257999986410141, 0.5170000195503235, 0 )

    Read the article

  • PHP anonymous functions scope question

    - by Dan
    Hi, I'm trying to sort an array of objects by a common property, however I cannot get my $property parameter to register in the inner function (I can use it in the outer one OK). The way I read the documentation, it sounded like the parameter would be available, have I misunderstood something? Here is what I have: public static function sortObjectsByProperty($objects, $property) { function compare_object($a, $b) { $a = $a->$property; $b = $b->$property; if ($a->$property == $b->$property) { return 0; } return ($a->$property > $b->$property) ? +1 : -1; } usort($objects, 'compare_object'); return $objects; } Any advice appreciated. Thanks.

    Read the article

  • In Coldfusion, how do I init a component that is located above the current path folder?

    - by Dan Sorensen
    If I have a folder structure that looks like this: / /bin/myComponent.cfc /reports/index.cfm How do I initiate myComponent.cfc from index.cfm? myService = createObject("component", "bin.myComponent"); Using the dot syntax, I know how to go to deeper folders, but how to do I go up a folder, and down into the other folder? Using slash syntax it would be something like this: ../bin/myComponent.cfc But createObject() doesn't work that way. I'd like to keep a relative path so that I can move this folder to another server without breaking the paths. Ideas? Thanks!

    Read the article

  • javax script how to call a function in JavaScript from Java

    - by Dan Howard
    Hi All, I'm trying to call a function in JavaScript via Java. This works fine when directly reading a script as a string but I'm using CompiledScripts. When I do this with a compiled script it gives me method not found if I also add bindings. Without bindings it works but of course the function fails because it needs the bindings. Any ideas? CompiledScript script = ... get script.... Bindings bindings = script.getEngine().createBindings(); Logger scriptLogger = LogManager.getLogger("TEST_SCRIPT"); bindings.put("log", scriptLogger); //script.eval(bindings); -- this way fails script.eval(); // -- this way works Invocable invocable = (Invocable) script.getEngine(); invocable.invokeFunction(methodName); TIA

    Read the article

  • How can I add an Items-like property to my User Control?

    - by Dan Tao
    It's pretty straightforward to add simple properties to a User Control that will appear in the desired categories in the Windows Forms designer, e.g.: [Category("Appearance")] public Color BackColor { get { return _textBox.BackColor; } set { _textBox.BackColor = value; } } What if I want to expose a more complex property, such as a collection of items of a type I define? I'm thinking something along the lines of the ListView.Items property, or the DataGridView.Columns property -- where the user of the control can access this complex property via a more specialized pop-up form (as opposed to a simple TextBox or ComboBox). Even a simple nudge in the right direction would be much appreciated.

    Read the article

  • Why won't my styles show in a Dynamics CRM 4 IFRAME?

    - by Dan Crowther
    I have created a web page (ASP.NET) that includes a stylesheet to mimic Dynamics CRM styles. This is to be used in a CRM IFRAME (within a form). The stylesheet is referenced as follows: <head id="Head1" runat="server"> <link href="Styles.css" rel="stylesheet" type="text/css" /> </head> When I load the page in Visual Studio, all is well. When I load it in CRM, none of the styles are shown and no images are displayed. If I browse directly to the image, I get a 404 error. However, the pages function correctly. I have set read permissions for "Everyone" on the server to see if that was causing a problem but it didn't help. I also tried putting a plain HTML page in the folder and that won't load either - again a 404. The page is installed in the ISV folder ..../isv/MyProject. Can anyone help? EDIT This is on a multi-tenancy system. On my test company (testcompany) if I browse to http://crm/testcompany/isv/MyProject/MyPage.aspx, the page is loaded (without styles and images). If I browse to http://crm/testcompany/isv/MyProject/TestImage.gif, the image is not shown. If I browse to http://crm/isv/MyProject/TestImage.gif, the image is shown. Does this suggest a problem with the server setup and the way CRM messes around with virtual directories?

    Read the article

  • Using TextOptions.TextFormattingMode with FormattedText

    - by dan gibson
    With WPF4 you can have non-blurry text by adding TextOptions.TextFormattingMode="Display" and TextOptions.TextRenderingMode="Aliased" to your xaml: <Window TextOptions.TextFormattingMode="Display" TextOptions.TextRenderingMode="Aliased"> This works fine for me except for when I draw text with DrawingContext.DrawText like this: void DrawText(DrawingContext dc) { FormattedText ft = new FormattedText("Hello World", System.Globalization.CultureInfo.CurrentCulture, System.Windows.FlowDirection.LeftToRight, new Typeface(FontFamily, FontStyle, FontWeight, FontStretch), FontSize, brush); dc.DrawText(ft, new Point(rect.Left, rect.Top)); } How can I draw non-blurry text with FormattedText? ie I want TextOptions.TextFormattingMode="Display" and TextOptions.TextRenderingMode="Aliased" to be used.

    Read the article

  • Accessing previous activity instances in a sequence activity

    - by Dan Revell
    This has a rather SharePoint spin to it but the problem is straight workflow. I've got a parallel replication activity which contains a sequence activity. The sequence activity contains a CreateTask activity, a CodeActivity, a OnTaskChanged activity and finally a CompleteTask activity. The idea is to create a task for each username passed into the ReplicatorActivity.InitialChildData property. Typically in workflow I bind a field to the CreateTask.TaskId and CreateTask.TaskProperties and inside the CreateTask.MethodInvoking I set these through the local bound fields. This works and my tasks all get created properly. However in the CodeActivity that follows, I want to then access the TaskProperties. The problem I am encountering is that this field holds the values of the final task to be created as the CreateTask runs for all the replications before the CodeActivity gets to runs. From the CodeActivity, here are two ways I've tried to access the CreateTask activity instance from the same context or instance or whatever the terminology is for the replicated sequence. CreateTask task = ((CreateTask)sender.Parent.GetActivityByName("createSoftwareRequestTask", true)); CreateTask createTask = (CreateTask)sender.Parent.Activities[0]; Unfortunately the CreateTask activities both refer back to the last task to be created and not the task from the context that the CodeActivity is executing within. Two reasons why this might be that I can think of. I'm not accessing the correct instance with my code. I am accessing the correct instance, but as the properties I require were bound to and set through local fields then their previous data was overwritten. I'm hitting a brick wall with my understanding of workflow with this and would very much appreciate some assistance here.

    Read the article

  • How to get ANTLR 3.2 to exit upon first error?

    - by Dan Becker
    In section 10.4, The Definitive ANTLR reference tells you to override mismatch() & recoverFromMismatchedSet() if you want to exit upon the first parsing error. But, at least in ANTLR 3.2, it appears that there is no mismatch() method, and the recoverFromMismatchedSet() documentation says that it is "Not Currently Used". So it appears things have changed since the book was published. What am I supposed to do instead to exit upon the first parsing error in ANTLR 3.2?

    Read the article

  • Binding a list belonging to another object in a custom model binder in ASP.NET MVC

    - by Dan
    I realize something like this has been asked, but this may be a little different Below is my Event object: Event : IEvent public int Id public string Title public List<EventContact> Contacts And EventContact: EventContact public int Id public string Name So, an Event has a list of EventContact' objects. Now, Event also implements IEvent - hence the custom model binder. I useIEventinstead of Event, so when the default model binder tries to do its thing, it lets me know it can't create anIEvent'. I have my view with populated with the contact info: <input type="text" name="contact[0].Name" value="DB Value"/> <input type="text" name="contact[1].Name" value="DB Value"/> <input type="text" name="contact[2].Name" value="DB Value"/> <!-- Event fields, etc --> So, in my custom model binder I am able to see all the value - sweet! The only thing is, I'm really not sure how to get all the contact fields and create a list of contacts from them, along with binding all the Event fields. Any and all help is appreciated!

    Read the article

  • Using the erlang mysql module, how is a database connection closed?

    - by Dan
    In using the erlang mysql module the exposed external functions are: %% External exports -export([start_link/5, start_link/6, start_link/7, start_link/8, start/5, start/6, start/7, start/8, connect/7, connect/8, connect/9, fetch/1, fetch/2, fetch/3, prepare/2, execute/1, execute/2, execute/3, execute/4, unprepare/1, get_prepared/1, get_prepared/2, transaction/2, transaction/3, get_result_field_info/1, get_result_rows/1, get_result_affected_rows/1, get_result_reason/1, encode/1, encode/2, asciz_binary/2 ]). From the this this, it is not apparent how to close a connection. How a connection closed?

    Read the article

  • using SET datatype in mysql

    - by Dan Snyder
    Is it possible to set a varaible to a query result such as: DECLARE result INT; SET result = (SELECT index FROM table WHERE data = 'xxxx' LIMIT 1); Assuming of course you know that there will only be one result set

    Read the article

  • How to customize the appearance of a tab bar?

    - by Dan Harrelson
    I am looking to customize the appearance of a tab bar. Specifically I want to: Change the default tabBar color Add a custom image on top of the tabBar Add custom images to tabBarButtons Change the font of tabBarButtons In a nutshell, I want all of the functionality of a tab bar but with a completely custom look. Should I start subclassing elements, or using categories or what?

    Read the article

  • What languages have a while-else type control structure, and how does it work?

    - by Dan
    A long time ago, I thought I saw a proposal to add an else clause to for or while loops in C or C++... or something like that. I don't remember how it was supposed to work -- did the else clause run if the loop exited normally but not via a break statement? Anyway, this is tough to search for, so I thought maybe I could get some CW answers here for various languages. What languages support adding an else clause to something other than an if statement? What is the meaning of that clause? One language per answer please.

    Read the article

  • PHP / MySQL - How to retrieve 2 separate sets of objects?

    - by Dan
    Hi, I have a set of models which correspond to tables in my database. I have been retrieving them easily enough, for example. $result = $mysqli->query('SOME SQL'); $post = $result->fetch_object; What would be the best approach for performing a join and also returning the related objects? For example, each post is created by a user, so for each row returned in the joined statement, both a page and user object should be returned. Any advice appreciated. Thanks.

    Read the article

  • How do I create an ImageView in java code, within an existing Layout?

    - by Dan T
    I'm looking for an easy way for the user to see how many drinks they've had for a BAC calculator. PICTURE OF THE APP, for reference On button press, I would like an image to be added to the screen, directly under the spinner and with left alignment. When I press the button again, I want another image to be added to the screen. So if I pressed the add beer button, a drawable of a beer would appear below the spinner. If I pressed the add beer button again, I want there to be TWO drawables of beers under the spinner, preferably with them being added from the right. (Also, having them reach their width limit, wrapping around, and starting again on the left, but below a full line, would be AWESOME) I can't figure out how to do this. I assume adding a ImageView in code to a relative layout (because it needs to be positioned to the right) would be the best route, but if it's possible in xml I'd be more than happy to use that. Any help?

    Read the article

  • JavaScript data formatting/pretty printer

    - by Dan
    I'm trying to find a way to 'pretty print' a JavaScript data structure in a human-readable form for debugging. I have a rather big and complicated data structure being stored in JS and I need to write some code to manipulate it. In order to work out what I'm doing and where I'm going wrong, what I really need is to be able to see the data structure in its entirety, and update it whenever I make changes through the UI. All of this stuff I can handle myself, apart from finding a nice way to dump a JavaScript data structure to a human-readable string. JSON would do, but it really needs to be nicely formatted and indented. I'd usually use Firebug's excellent DOM dumping stuff for this, but I really need to be able to see the entire structure at once, which doesn't seem to be possible in Firebug. Any suggestions welcome, thanks in advance.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >