Search Results

Search found 1020 results on 41 pages for 'car'.

Page 11/41 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Do functional generics exist or what is the correct name for them if they do?

    - by voroninp
    Consider the following generic class public class EntityChangeInfo<EntityType,TEntityKey> { ChangeTypeEnum ChangeType {get;} TEntityKeyType EntityKey {get;} } Here EntityType unambiguously defines TEntityKeyType. So it would be nice to have some kind of types' map public class EntityChangeInfo<EntityType,TEntityKey> with map < [ EntityType : Person -> TEntityKeyType : int] [ EntityType : Car -> TEntityKeyType : CarIdType ]> { ChangeTypeEnum ChangeType {get;} TEntityKeyType EntityKey {get;} } Another one example is: public class Foo<TIn> with map < [TIn : Person -> TOut1 : string, TOut2 : int, ..., TOutN : double ] [TIn : Car -> TOut1 : int, TOut2 :int, ..., TOutN : Price ] > { TOut1 Prop1 {get;set;} TOut2 Prop2 {get;set;} ... TOutN PropN {get;set;} } The reasonable question how this can be interpreted by the compiler? Well, for me it is just the sortcut for two structurally similar classes: public sealed class Foo<Person> { string Prop1 {get;set;} int Prop2 {get;set;} ... double PropN {get;set;} } public sealed class Foo<Car> { int Prop1 {get;set;} int Prop2 {get;set;} ... Price PropN {get;set;} } But besides this we could imaging some update of the Foo<: public class Foo<TIn> with map < [TIn : Person -> TOut1 : string, TOut2 : int, ..., TOutN : double ] [TIn : Car -> TOut1 : int, TOut2 :int, ..., TOutN : Price ] > { TOut1 Prop1 {get;set;} TOut2 Prop2 {get;set;} ... TOutN PropN {get;set;} public override string ToString() { return string.Format("prop1={0}, prop2={1},...propN={N-1}, Prop1, Prop2,...,PropN); } } This all can seem quite superficial but the idea came when I was designing the messages for our system. The very first class. Many messages with the same structrue should be discriminated by the EntityType. So the question is whether such construct exist in any programming language?

    Read the article

  • Usercontrol databinding within a databound datagridview

    - by user328259
    Good day. I'm developing a Windows application and working with Windows Forms; .Net 2.0. I have an issue databinding a generic List of Car Rental Companies to a DataGridView when that list contains (one of its properties) anoother generic List of Car Makes. I also have a UserControl that I need to bind to this [inner] generic list ... Class CarRentalCompany contains: string Name, string Location, List CarMakes Class CarMake contains: string Name, bool isFord, bool isChevy, bool isOther The UserControl has a label for CarMake.Name and 3 checkboxes for each of the booleans of the class. HOw do I make this user control bindable for the class? In my form, I have a DataGridView binded to the CarRentalCompany object. The list CarMakes could be 0 or more items and I can add these as necessary. How do I establish the binding of CarRentalCompanies properly so CarMakes will bind accordingly?? For example, I have: List CarRentalCompanies = new List(); CarRentalCompany company1 = new CarRentalCompany(); company1.Name = "Acme Rentals"; company1.Location = "New York, NY"; company1.CarMakes = new List<CarMake>(); CarMake car1 = new CarMake(); car1.Name = "The Yellow Car"; car1.isFord = true; car1.isChevy = false; car1.isOther = false; company1.CarMakes.Add(car1); CarMake car2 = new CarMake(); car2.Name = "The Blue Car"; car2.isFord = false; car2.isChevy = true; car2.isOther = false; company1.CarMakes.Add(car2); CarMake car3 = new CarMake(); car3.Name = "The Purple Car"; car3.isFord = false; car3.isChevy = false; car3.isOther = true; company1.CarMakes.Add(car3); CarRentalCompanies.Add(company1); CarRentalCompany company2 = new CarRentalCompany(); company1.Name = "Z-Auto Rentals"; company1.Location = "Phoenix, AZ"; company1.CarMakes = new List<CarMake>(); CarMake car4 = new CarMake(); car4.Name = "The OrangeCar"; car4.isFord = true; car4.isChevy = false; car4.isOther = false; company2.CarMakes.Add(car4); CarMake car5 = new CarMake(); car5.Name = "The Red Car"; car5.isFord = true; car5.isChevy = false; car5.isOther = false; company2.CarMakes.Add(car5); CarMake car6 = new CarMake(); car6.Name = "The Green Car"; car6.isFord = true; car6.isChevy = false; car6.isOther = false; company2.CarMakes.Add(car6); CarRentalCompanies.Add(company2); I load my form and in my load form I have the following: Note: CarDataGrid is a DataGridView BindingSource bsTheRentals = new BindingSource(); DataGridViewTextBoxColumn companyName = new DataGridViewTextBoxColumn(); companyName.DataPropertyName = "Name"; companyName.HeaderText = "Company Name"; companyName.Name = "CompanyName"; companyName.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; DataGridViewTextBoxColumn companyLocation = new DataGridViewTextBoxColumn(); companyLocation.DataPropertyName = "Location"; companyLocation.HeaderText = "Company Location"; companyLocation.Name = "CompanyLocation"; companyLocation.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; ArrayList carMakeColumnsToAdd = new ArrayList(); // Loop through the CarMakes list to add each custom column for (int intX=0; intX < CarRentalCompanies.CarMakes[0].Count; intX++) { // Custom column for user control string carMakeColumnName = "carColumn" + intX; CarMakeListColumn carMakeColumn = new DataGridViewComboBoxColumn(); carMakeColumn.Name = carMakeColumnName; carMakeColumn.DisplayMember = CarRentalCompanies.CarMakes[intX].Name; carMakeColumn.DataSource = CarRentalCompanies.CarMakes; // this is the CarMAkes List carMakeColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; carMakeColumnsToAdd.Add(carMakeColumn); } CarDataGrid.DataSource = bsTheRentals; CarDataGrid.Columns.AddRange(new DataGridViewColumn[] { companyName, companylocation, carMakeColumnsToAdd }); CarDataGrid.AutoGenerateColumns = false; The code I provided does not work because I am unfamiliar with UserControls and custom DataGridViewColumns and DataGridViewCells - I know I must derive from these classes in order to use my User Control properly. I appreciate any advice/assistance/help in this. Thank you. Lawrence

    Read the article

  • When the canonical page itself changes url

    - by lulalala
    This is a continuation of the question: How to handle canonical url changes like Stack Overflow. Say I have the canon url: questions/11/car <---canonically-linked-from--- questions/11/ What will happen if I want to change the canon url to questions/11/car-with-sgx Obviously, questions/11/ will point to the new canon url. But how should the old questions/11/car change to the new one? There are two ways: 301 redirect that to new canon url the old canon url canonically link to the new canon url According to this post: [By using canonical link instead of redirect,] OldPage.html’s rankings will drop over time due to fewer internal links, but the canonical tag won’t make it disappear entirely. It could theoretically remain in their index until one of the following occurs: it is redirected permanently via 301 it returns a 404 for an extended period of time (they will keep checking for a while before dropping a URL) a meta robots “noindex” tag is added If this is true, I really need to use redirect from old canon url to the new canon url, which means I need to keep a log of previous old canon urls of this content, so I know when I can redirect. This is a bit of a hassle to do.

    Read the article

  • Random Monday Thoughs

    - by Terry Goldman
    On this Monday morning my thoughts center on why is it so hard to embrace governance, any form of governance for that matter, be it software development governance, SOA governance, data governance, IT governance, so on a so fourth?Most customers that I meet tend to think that they don't need don't need governance as all is good within the enterprise. The question I generally pose to colleges and customers, is you have to think of governance as an insurance policy. Take of instance, if you just bought a new car, perhaps your "dream" car, would you drive it on the open streets without having the car insured? Probably not.Governance is what insurance is to new cars, be it to SOA, IT transformations and software development. Governance is a insurance policy against risk of failure. Now once I put it in this context, ask yourself, does governance have value to your organization? Most people now get it. Once the seed of governance is planted at the executive level of an organization, it becomes a exercise in planting an that idea into key personnel within the organization. Then the justification for governance grows and grows across the enterprise.Thats my food for though in this Monday morning.FYI, stay tuned for an upcoming multi-part article on using Oracle Enterprise Repository to build a Enterprise Continuum as described in TOGAF v9.0.

    Read the article

  • Perpendicularity of a normal and a velocity?

    - by Milo
    I'm trying to fake angular velocity on my vehicle when it hits a wall by getting the dot product of the normal of the edge the car is hitting and the vehicle's velocity: Vector2D normVel = new Vector2D(); normVel.equals(vehicle.getVelocity()); normVel.normalize(); float dot = normVel.dot(outNorm); dot = -dot; vehicle.setAngularVelocity(vehicle.getAngularVelocity() + (dot * vehicle.getVelocity().length() * 0.01f)); outNorm is the normal of the wall. The problem is it only works half the time. It seems no matter what, the car always goes clockwise. If the car should head clockwise: -------------------------------------- / / I want the angular velocity to be positive, otherwise if it needs to go CCW: -------------------------------------- \ \ Then the angular velocity should be negative... What should I change to achieve this? Thanks Hmmm... Im not sure why this is not working... for(int i = 0; i < buildings.size(); ++i) { e = buildings.get(i); ArrayList<Vector2D> colPts = vehicle.getRect().getCollsionPoints(e.getRect()); float dist = OBB2D.collisionResponse(vehicle.getRect(), e.getRect(), outNorm); for(int u = 0; u < colPts.size(); ++u) { Vector2D p = colPts.get(u).subtract(vehicle.getRect().getCenter()); vehicle.setTorque(vehicle.getTorque() + p.cross(outNorm)); }

    Read the article

  • How do I change the Creation/Mod Date of all folders on a USB drive using Touch command?

    - by Chad--24216
    I've got a USB drive with mp3 music on it that I play in my car. My car has a USB drive port. Problem is that the car sorts the music by Creation/Modification Date (and not alphabetically). This makes it a pain to find what artist I'm looking for. To solve this problem, I need a way to "update" the Creation/Modification Date for all folders on the USB drive every time I add a new folder of music to the USB drive. Anyone know how I can do this? The Touch command works great, but the format touch <filename> would take forever to do on each folder on the drive. Anyway to select all folders on the drive and then touch <all folders>? On my USB drive I have a folder for each album and the songs within each respective folder, like so: Album-1-folder Album-2-folder I need to apply the Touch command to each of the "album" folders on the drive. I stumbled upon a simple solution to solve this issue:touch /media/USB_Drive/*

    Read the article

  • Dynamic endpoint binding in Oracle SOA Suite by Cattle Crew

    - by JuergenKress
    Why is dynamic endpoint binding needed? Sometimes a BPEL process instance has to determine at run-time which implementation of a web service interface is to be called. We’ll show you how to achieve that using dynamic endpoint binding. Let’s imagine the following scenario: we’re running a car rental agency called RYLC (Rent Your Legacy Car) which operates different locations. The process of renting a car is basically identical for all locations except for the determination which cars are currently available. This is depicted in the following diagram: There are three different implementations of the GetAvailableCars service. But how can we achieve calling them dynamically at run-time using Oracle SOA Suite? How to dynamically set the service endpoint There are just a couple of implementation steps we need to perform to enable dynamic endpoint binding: create a new SOA project in JDeveloper add a CarRental BPEL process add an external reference to the GetAvailableCars service within the composite create a DVM file containing the URI’s by which the services for the different locations can be accessed set the endpointURI property on the Invoke component calling the GetAvailableCars service (value is taken from the DVM file) Read the complete article here. SOA & BPM Partner Community For regular information on Oracle SOA Suite become a member in the SOA & BPM Partner Community for registration please visit www.oracle.com/goto/emea/soa (OPN account required) If you need support with your account please contact the Oracle Partner Business Center. Blog Twitter LinkedIn Facebook Wiki Technorati Tags: Cattle crew,SOA binding,SOA Community,Oracle SOA,Oracle BPM,Community,OPN,Jürgen Kress

    Read the article

  • OOP concept: is it possible to update the class of an instantiated object?

    - by Federico
    I am trying to write a simple program that should allow a user to save and display sets of heterogeneous, but somehow related data. For clarity sake, I will use a representative example of vehicles. The program flow is like this: The program creates a Garage object, which is basically a class that can contain a list of vehicles objects Then the users creates Vehicles objects, these Vehicles each have a property, lets say License Plate Nr. Once created, the Vehicle object get added to a list within the Garage object --Later on--, the user can specify that a given Vehicle object is in fact a Car object or a Truck object (thus giving access to some specific attributes such as Number of seats for the Car, or Cargo weight for the truck) At first sight, this might look like an OOP textbook question involving a base class and inheritance, but the problem is more subtle because at the object creation time (and until the user decides to give more info), the computer doesn't know the exact Vehicle type. Hence my question: how would you proceed to implement this program flow? Is OOP the way to go? Just to give an initial answer, here is what I've came up until now. There is only one Vehicle class and the various properties/values are handled by the main program (not the class) through a dictionary. However, I'm pretty sure that there must be a more elegant solution (I'm developing using VB.net): Public Class Garage Public GarageAdress As String Private _ListGarageVehicles As New List(Of Vehicles) Public Sub AddVehicle(Vehicle As Vehicles) _ListGarageVehicles.Add(Vehicle) End Sub End Class Public Class Vehicles Public LicensePlateNumber As String Public Enum VehicleTypes Generic = 0 Car = 1 Truck = 2 End Enum Public VehicleType As VehicleTypes Public DictVehicleProperties As New Dictionary(Of String, String) End Class NOTE that in the example above the public/private modifiers do not necessarily reflect the original code

    Read the article

  • Determinism in multiplayer simulation with Box2D, and single computer

    - by Jake
    I wrote a small test car driving multiplayer game with Box2D using TCP server-client communcations. I ran 1 instance of server.exe and 2 instance of client.exe on the same machine that I code and compile the executables. I type inputs (WASD for a simple car movement) into one of the 2 clients and I can get both clients to update the simulation. There are 2 cars in the simulation. As long as the cars do not collide, I get the same identical output on both client.exe. I can run the car(s) around for as long as I could they still update the same. However, if I start to collide the cars, very quickly they go out of sync. My tools: Windows 7, C++, MSVS 2010, Box2D, freeGlut. My Psuedocode: // client.exe void timer(int value) { tcpServer.send(my_inputs); foreach(i = player including myself) inputs[i] = tcpServer.receive(); foreach(i = player including myself) players[i].process(inputs[i]); myb2World.step(33, 8, 6); // Box2D world step simulation foreach(i = player including myself) renderer.render(player[i]); glutTimerFunc(33, timer, 0); } // server.exe void serviceloop { while(all clients alive) { foreach(c = clients) tcpClients[c].receive(&inputs[c]); // send input of each client to all clients foreach(source = clients) { foreach(dest = clients) { tcpClients[dest].send(inputs[source]); } } } } I have read all over the internet and SE the following claims (paraphrased): Box2D is deterministic as long as floating point architecture/implementation is the same. (For any deterministic engine) Determinism is gauranteed if playback of recorded inputs is on the same machine with exe compiled using same compiler and machine. Additionally my server.exe and client.exe gameloop is single thread with blocking socket calls and fixed time step. Question: Can anyone explain what I did wrong to get different Box2D output?

    Read the article

  • techniques for displaying vehicle damage

    - by norca
    I wonder how I can displaying vehicle damage. I am talking about an good way to show damage on screen. Witch kind of model are common in games and what are the benefits of them. What is state of the art? One way i can imagine is to save a set of textures (normal/color/lightmaps, etc) to a state of the car (normal, damage, burnt out) and switch or blending them. But is this really good without changing the model? Another way i was thinking about is preparing animations for different locations on my car, something like damage on the front, on the leftside/rightside or on the back. And start blending the specific animation. But is this working with good textures? Whats about physik engines? Is it usefull to use it for deforming vertexdata? i think losing parts of my car (doors, sirens, weapons) can looks really nice. my game is a kind of rts in a top down view. vehicles are not the really most importend units (its no racing game), but i have quite a lot in. thx for help

    Read the article

  • How to prioritize related game entity components?

    - by Paul Manta
    I want to make a game where you have to run over a bunch of zombies with your car. When moving around, the zombies have a few things to take into consideration: When there's no player around they might just roam about randomly. And even when some other component dictates a specific direction, they should wobble to the left and right randomly (like drunk people). This implies a small, random, deviation in their movement. They should avoid static obstacles. When they see they are headed towards a wall, they should reorient themselves. They should avoid the car. They should try to predict where the car will be based on its velocity and try to move out of the way. When they can, they should try to get near the player. All these types of decisions they have to do seem like they should be implemented in different components. But how should I manage them? How can I give different components different weights that reflect the importance of each decision (in a given situation)? I would need some other component that acts as a manager, but do you have any tips on how I should implement it? Or maybe there's a better solution?...

    Read the article

  • How do I make cars on a one-dimensional track avoid collisions?

    - by user990827
    Using three.js, I use a simple spline to represent a road. Cars can only move forward on the spline. A car should be able to slow-down behind a slow moving car. I know how to calculate the distance between 2 cars, but how to calculate the proper speed in each game update? At the moment I simply do something like this: this.speed += (this.maxSpeed - this.speed) * 0.02; // linear interpolation to maxSpeed // the position on the spline (0.0 - 1.0) this.position += this.speed / this.road.spline.getLength(); This works. But how to implement the slow-down part? // transform from floats (0.0 - 1.0) into actual units var carInFrontPosition = carInFront.position * this.road.spline.getLength(); var myPosition = this.position * this.road.spline.getLength(); var distance = carInFrontPosition - myPosition; // WHAT TO DO HERE WITH THE DISTANCE? // HOW TO CALCULATE MY NEW SPEED? Obviously I have to somehow take current speed of the cars into account for calculation. Besides different maxSpeeds, I want each car to also have a different mass (causing it to accelerate slower/faster). But this mass has to be then also taken into account for braking (slowing down) so they don't crash into each other.

    Read the article

  • MySQL - Calculating fields on the fly vs storing calculated data

    - by Christian Varga
    Hi Everyone, I apologise if this has been asked before, but I can't seem to find an answer to a question that I have about calculating on the fly vs storing fields in a database. I read a few articles that suggested it was preferable to calculate when you can, but I would just like to know if that still applies to the following 2 examples. Example 1. Say you are storing data relating to a car. You store the fuel tank size in litres, and how many litres it uses per 100km. You also want to know how many KMs it can travel, which can be calculated from the tank size and economy. I see 2 ways of doing this: When a car is added or updated, calculate the amount of KMs and store this as a static field in the database. Every time a car is accessed, calculate the amount of KMs on the fly. Because the cars economy/tank size doesn't change (although it could be edited), the KMs is a pretty static value. I don't see why we would calculate it every single time the car is accessed. Wouldn't this waste cpu time as opposed to simply storing it in a separate field in the database and calculating only when a car is added or updated? My next example, which is almost an entirely different question (but on the same topic), relates to counting children. Let's say we have a app which has categories and items. We have a view where we display all the categories, and a count of all the items inside each category. Again, I'm wondering what's better. To perform a MySQL query to count all the items in each category every single time the page is accessed? Or store the count in a field in the categories table and update when an item is added / deleted? I know it is redundant to store anything that can be calculated, but I worry that calculating fields or counting records might be slow as opposed to storing the data in a field. If it's not then please let me know, I just want to learn about when to use either method. On a small scale I guess it wouldn't matter either way, but apps like Facebook, would they really count the amount of friends you have every time someone views your profile or would they just store it as a field? I'd appreciate any responses to both of these scenarios, and any resource that might explain the benefits of calculating vs storing. Thanks in advance, Christian

    Read the article

  • Why the only hidden field that is being filled from GET action is not being passed in model?

    - by user1807954
    Sorry for the long title, I didn't know how to make it any shorter. My code: My model: public class CarFilter { public String carMake { get; set; } public String carModel { get; set; } public String carEdition { get; set; } . . . public String SortBy { get; set; } } public class CarSearch : CarFilter { public List<Car> Car { get; set; } } My controller: public ActionResult SearchResult(CarSearch search) { var cars = from d in db.Cars select d; if (Request.HttpMethod == "POST") { search.SortBy = "Price"; } search.Car = new List<Car>(); search.Car.AddRange(cars); var temp = new List<CarSearch>(); temp.Add(search); return View(temp); } My Index view (where user filters results): @model IEnumerable<Cars.Models.CarSearch> @using (Html.BeginForm("SearchResult", "Home", FormMethod.Post)){..forms and other stuff..} My SearchResult view (where user sees the results of filtration): @model IEnumerable<Cars.Models.CarSearch> @using (Html.BeginForm("SearchResult", "Home", FormMethod.Get)) { @Html.Hidden("carMake") @Html.Hidden("carModel") @Html.Hidden("carEdition") . . . @Html.Hidden("SortBy", temp.SortBy) <input name="SortBy" class="buttons" type="submit" value="Make"/> My goal What I'm trying to do is when user clicked on sort by Make it will have to GET back all the variables in hidden field back to the SearchResult action in order to sort the result (same filtered results). Result Is: <input id="SortBy" name="SortBy" type="hidden" value=""/>. The value is null and it's not being passed but all the other hidden fields such as carMake and etc have value. But when I use foreach it works perfect. Question Why is this like this? the SortBy is in the same model class as other fields in the view. The only difference is that SortBy is not being filled in the Index view with other fields, instead it's being filled in controller action. What is the explanation for this? Am I missing any C# definition or something such as dynamic objects or something?

    Read the article

  • Binary Trees in Scheme

    - by Javier
    Consider the following BNF defining trees of numbers. Notice that a tree can either be a leaf, a node-1 with one subtrees, or a node-2 with two subtrees. tree ::= (’leaf number) | (’node-1 tree) | (’node-2 tree tree) a. Write a template for recursive procedures on these trees. b. Define the procedure (leaf-count t) that returns the number of leaves in t > (leaf-count ’(leaf 5)) 1 > (leaf-count ’(node-2 (leaf 25) (leaf 17))) 2 > (leaf-count ’(node-1 (node-2 (leaf 4) (node-2 (leaf 2) (leaf 3))))) 3 Here's what I have so far: ;define what a leaf, node-1, and node-2 is (define leaf list) (define node-1 list) (define node-2 list) ;procedure to decide if a list is a leaf or a node (define (leaf? tree) (number? (car tree))) (define (node? tree) (pair? (car tree))) (define (leaf-count tree) (cond ((null? tree) 0) ((number? tree) 0) ((leaf? tree) 1) (else (+ (leaf-count (car tree)) (leaf-count (cdr tree)))))) It looks like it should run just fine, but when I try to run it using a simple test case like (leaf-count '(leaf 5)) I get the following error message: car: expects argument of type pair; given leaf What does this error message mean? I am defining a leaf as a list. But for some reason, it's not seeing that and gives me that error message.

    Read the article

  • Xpath that evaluates -all- attributes?

    - by Tres
    I maybe be trying to do something invalid here, but maybe someone smarter than me knows the correct syntax to solve my problem. Given: <group code="vehicle"> <line code="car"> <cell> <box code="price">1000.00</box> </cell> </line> <line code="car"> <cell code="sports"> <box code="price">500.00</box> </cell> </line> </group> If I use //*[@code="vehicle"]//*[@code="car"]//*[@code="price"], I will get both boxes returned (1000.00 and 500.00)--as expected but not what I want. Is there an xpath syntax that will evaluate against all nodes that have an attribute of @code rather than skipping it if it doesn't match with the end result being that I only get back the first box (price of 1000.00)? Like asking, choose the first node with @code and that @code must equal "vehicle", then choose the next node with @code and that @code must equal "car", then choose the next node with @code and @code must equal "price".

    Read the article

  • faster way to change xml to array(grails to flex)

    - by Anthony Umpad
    I have a large xml passed from grails to flex. When flex receives the xml, it converts the xml into an associative array object. Given the large xml file, it takes too long to complete the loop, is there any way in flex to make conversion faster? Below is my sample code. <xml> <car> <model>Vios</model> <type>Sedan</type> <color>Blue</color> </car> <car> <model>Camry</model> <type>Luxury</type> <color>Black</color> </car> </xml> *converted to the flex associative array below.* [Vios].type = Sedan .color = Blue [Camry].type = Luxury .color = Black *Below is a code I used in flex to convert the xml to the associative array object* var tempXML=xml.children() var tempArray:Array= new Array() for(var i:int=0;i<tempXML.length();i++) { tempArray[tempXML[i].@model]= new Object(); tempArray[tempXML[i].@model].color = tempXML[i][email protected](); tempArray[tempXML[i].@model].type = tempXML[i][email protected](); }

    Read the article

  • Scheme: what are the benefits of letrec?

    - by Ixmatus
    While reading "The Seasoned Schemer" I've begun to learn about letrec. I understand what it does (can be duplicated with a Y-Combinator) but the book is using it in lieu of recurring on the already defined function operating on arguments that remain static. An example of an old function using the defined function recurring on itself (nothing special): (define (substitute new old lat) (cond ((null? l) '()) ((eq? (car l) old) (cons new (substitute new old (cdr l)))) (else (cons (car l) (substitute new old (cdr l)))))) Now for an example of that same function but using letrec: (define (substitute new old lat) (letrec ((replace (lambda (l) (cond ((null? l) '()) ((eq? (car l) old) (cons new (replace (cdr l)))) (else (cons (car l) (replace (cdr l)))))))) (replace lat))) Aside from being slightly longer and more difficult to read I don't know why they are rewriting functions in the book to use letrec. Is there a speed enhancement when recurring over a static variable this way because you don't keep passing it?? Is this standard practice for functions with arguments that remain static but one argument that is reduced (such as recurring down the elements of a list)? Some input from more experienced Schemers/LISPers would help!

    Read the article

  • SVG <image> doesn't work in <defs> on Chrome

    - by avladev
    I want to use image in a group definded in defs tag. But on Chrome nothing works. In Firefox only the .png file is displayd. Only Rectangle apears but with strange bug in Chrome. Is this is supported by SVG or im not using it right. plane.svg <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg baseProfile="full" width="500" height="500" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <defs> <g id="car"> <rect x="0" y="0" width="30" height="30" fill="#ff0000" /> <image xlink:href="items/car.svg" x="0" y="0" width="30" height="30" /> <image xlink:href="items/t6k.png" x="100" y="100" width="140" height="140" /> </g> </defs> <use xlink:href="#car" x="0" y="0" width="600" height="600" /> </svg> images/car.svg <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg baseProfile="full" width="30" height="30" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"> <rect x="0" y="0" width="30" height="30" fill="red" stroke="green" stroke-width="3"/> </svg> Download code: http://www.4shared.com/file/9gNi5gCO/svg_bug.html

    Read the article

  • [nHibernate] casting string to bool using nHibernate Criteria

    - by code-zoop
    I have an nHibernate query using Criteria, and I am trying to cast a string to bool in the query itself. I have done the same with casting a string to int, and that works well (the "DataField" property is "1" as a string): var result = Session .CreateCriteria<Car>() .Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.Int32, Projections.Property("DataField"), 1)) .List<Car>(); tx.Commit(); But I am trying to do the same with bool, but I do not get the expected result: var result = Session .CreateCriteria<Car>() .Add(Restrictions.Eq((Projections.Cast(NHibernateUtil.bool, Projections.Property("DataField"), true)) .List<Car>(); tx.Commit(); "DataField" is the string "True", but the result in an empty list, where it should contain 100 elements with the "DataField" property string set to "True". I have tried with the string "true", and "1", but the result is still an empty List. [EDIT] As Commented below, I could check for the string "True" or "False", but I would say this is a more general question than just for the Boolean. Note that the idea is to have some sort of key value representation of the data, where the value can be different data types. I need the value table to contain all data, so storing the data as string seems like the cleanest solution! I have been able to use the method above to store both int and double as string, and to the cast in the query, but I have not succeeded using the same method for DateDime and Boolean. And for DateTime it is crucial to have the actual DateTime object. How can I make the cast from string to bool, and string to DateTime work in the queries? Thanks

    Read the article

  • How to Develop Dynamic Plug-In Based Functionality in C#

    - by Matthew
    Hello: I've been looking around for different methods of providing plug-in support for my application. Ideally, I will be creating a core functionality and based on different customers developing different plug-ins/addons such as importing, exporting data etc... What are the some methods available for making a C# application extensible via a plug-in architecture? Lets make up an example. If we have a program that consists of a main menu ( File, Edit, View, et al. ) along with a TreeView that displays different brands of cars grouped by manufacturer ( Ford, GM, for now). Right clicking on a car displays a context menu with the only option being 'delete car'. How could you develop the application so that plug-ins could be deployed so that you could allow one customer to see a new brand in the TreeView, let's say Honda, and also extent the car context menu so that they may now 'paint a car'? In Eclipse/RCP development this is easily handled by extension points and plug-ins. How does C# handle it? I've been looking into developing my own plug-in architecture and reading up on MEF.

    Read the article

  • Java Inheritance doubt in parameterised collection

    - by Gala101
    It's obvious that a parent class's object can hold a reference to a child, but does this not hold true in case of parameterised collection ?? eg: Car class is parent of Sedan So public void doSomething(Car c){ ... } public void caller(){ Sedan s = new Sedan(); doSomething(s); } is obviously valid But public void doSomething(Collection<Car> c){ ... } public void caller(){ Collection<Sedan> s = new ArrayList<Sedan>(); doSomething(s); } Fails to compile Can someone please point out why? and also, how to implement such a scenario where a function needs to iterate through a Collection of parent objects, modifying only the fields present in parent class, using parent class methods, but the calling methods (say 3 different methods) pass the collection of three different subtypes.. Ofcourse it compiles fine if I do as below: public void doSomething(Collection<Car> c){ ... } public void caller(){ Collection s = new ArrayList<Sedan>(); doSomething(s); }

    Read the article

  • Scheme Function to reverse elements of list of 2-list

    - by sudhirc
    This is an exercise from EOPL. Procedure (invert lst) takes lst which is a list of 2-lists and returns a list with each 2-list reversed. (define invert (lambda (lst) (cond((null? lst ) '()) ((= 2 (rtn-len (car lst))) ( cons(swap-elem (car lst)) (invert (cdr lst)))) ("List is not a 2-List")))) ;; Auxiliry Procedure swap-elements of 2 element list (define swap-elem (lambda (lst) (cons (car (cdr lst)) (car lst)))) ;; returns lengh of the list by calling (define rtn-len (lambda (lst) (calc-len lst 0))) ;; calculate length of the list (define calc-len (lambda (lst n) (if (null? lst) n (calc-len (cdr lst) (+ n 1))))) This seems to work however looks very verbose. Can this be shortened or written in more elegant way ? How I can halt the processing in any of the individual element is not a 2-list? At the moment execution proceed to next member and replacing current member with "List is not a 2-List" if current member is not a 2-list.

    Read the article

  • What is the Rule of Thumb on Exposing Encapsulated Class Methods

    - by javamonkey79
    Consider the following analogy: If we have a class: "Car" we might expect it to have an instance of "Engine" in it. As in: "The car HAS-A engine". Similarly, in the "Engine" class we would expect an instance of "Starting System" or "Cooling System" which each have their appropriate sub-components. By the nature of encapsulation, is it not true that the car "HAS-A" "radiator hose" in it as well as the engine? Therefore, is it appropriate OO to do something like this: public class Car { private Engine _engine; public Engine getEngine() { return _engine; } // is it ok to use 'convenience' methods of inner classes? // are the following 2 methods "wrong" from an OO point of view? public RadiatorHose getRadiatorHose() { return getCoolingSystem().getRadiatorHose(); } public CoolingSystem getCoolingSystem() { return _engine.getCoolingSystem(); } } public class Engine { private CoolingSystem _coolingSystem; public CoolingSystem getCoolingSystem() { return _coolingSystem; } } public class CoolingSystem { private RadiatorHose _radiatorHose; public RadiatorHose getRadiatorHose() { return _radiatorHose; } } public class RadiatorHose {//... }

    Read the article

  • Listbox - selected item to call the class method directly using reflection

    - by Karan
    I have a problem scenario like this:- 1) Listbox with values like Car, Scooter and Bike. A button to click. <div> <asp:ListBox ID="lst" runat="server"> <asp:ListItem Text="Bike" Value="Bike"></asp:ListItem> <asp:ListItem Text="Car" Value="Car"></asp:ListItem> <asp:ListItem Text="Scooter" Value="Scooter"></asp:ListItem> </asp:ListBox> <br /> <br /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Invoke" /> </div> 2) Now i have three different class like below:- class Car { static string getData() { return "I like cars"; } } class Bike { static string getData() { return "I like Bike"; } } class Scooter { static string getData() { return "I dont like scooter"; } } 3) Now on the button click event handler "Button1_Click", i want to call the getData() method based on the selected value from the listbox using the REFLECTION only. Please help me out.

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >