types

Java return problem

public void question(int col, int n, Node<Integer> part_soln) { if (col==0) stack.push(part_soln); else for (int row=1; row<=n; row++) { if (!exists(row,part_soln) && !unsafe(col,row,col+1,part_soln)) { Node<Integer> new_soln = new Node<Integer>(row,part_soln); questi...

Method to return a generic type when passing in a delegate as a parameter

I'm trying to 'genericize' some code we have spattered around our system. I want to: return a generic type, pass in some kind of delegate containing the method to be called. I'm pretty new to generics so any help appreciated. Below is where my finger in the air is(!) public static T ReturnSingleObject<T>(Func<string, int, T> dynam...

What variable type use to represent a Money in SSIS

I need to load a Money value in a variable in SSIS using a "Execute SQL Task" component. I map the return column of a SELECT to a variable. I've declared the variable "UnknownMoney" as a Double or a Single, but i always receive the error: Error: 0xC002F309 at Load Dummy vars, Execute SQL Task: An error occurred while assigning a value t...

Best practice for checking data types at runtime objective-c

Hi all, I have JSON data being provided to my application but unfortunatly it is not very well formed. Sometimes I am getting String representations of numbers when I am expecting numbers. For some reason some values may have a prefix of whitespace. What is the best way to deal with this? Currently I am forced to check the types vi...

Using real world units instead of types

I have a project with many calculations involving a lot of real world units : Distance; Temperature; Flow rate; ... This project involves complicated and numerous calculation formulas. That's why I supposed the use of custom types like Temperature, Distance... can be good for code readability. For example: Temperature x = -55.3; Me...

wordpress custom post type rewrite rule pagination for author

i'm using Wordpress 3.0.1 and i have made custom post-type called 'dienasgramatas'. my plugin also makes custom rewrite rules for displaying all posts from this post type and even custom permalink structure to query posts with this post type coming from defined author, but i can't create rule for pagination: the one that works: $new_ru...

[Haskell] Conflicting Definitions in Pattern Matching

I just started learning Haskell and I ran into a problem in 2-adic type classes. Here's the important code: data Rectangle = NoRect | Rect (Float,Float) (Float,Float) | Pane deriving (Show) class Collision s1 s2 where collides :: s1 -> s2 -> Bool instance (Collision Rectangle Rectangle) where collides (Rect (aOrX, aOrY...

Create an anonymous type from reflection ParamInfo[]

i want to create an anonymous type inside a function, when the anonymous type properties are the function parameters. for example, for the function: private bool CreatePerson(string FirstName, string LasName, int Age, int height); i will have an anonymous type with the properties: FirstName,LasName,Age and height. and the values of the...

Java: how to implement `toArray` for `Collection`

Right now, I have: public <T> T[] toArray(T[] old) { T[] arr = Arrays.copyOf(old, old.length + size()); int i = old.length; for(E obj : this) { arr[i] = old.getClass().getComponentType().cast(obj); ++i; } return arr; } (Note that this does not follow the contract ...

Types comparison in VB.NET

How i can compare type data type in VB.NET? My code: Private Function Equal(ByVal parameter As String, ByVal paramenterName As String, ByVal dataType As Type) As String If dataType = String Then return 1; End If End Function Any ideas? ...

strange type conversion

I just can not figure out the following code. int d = 5; float f = 3.8f; int ret = d*f; The ret is 18, not 19 as I expected. Why? ...

Wordpress - Query if a custom post type has any posts - from outside the loop

I'm making a restaurant menu using custom post types for the different menu sections. I used the excellent Custom Post Types UI plugin and the Verve Meta Boxes plugin. I'm then flowing them out into separate loops with several segments of the below code: <?php $hotfood = get_posts( array('post_type' => 'hotfood', 'posts_per_page...

Convert from Object to Original Class

I'm storing a instance of Entry class in an Object. Entry newentry = new Entry(j, 0.0); Object test = newentry; How can I convert the test Object back into an Entry class to access the Entry class method getValue()? ...

NSCoder and custom types

How do you use NSCoder to encode and decode custom types? For example, how would you use NSCoder with an instance of "STATE" where: typedef enum { ON, OFF } STATE; ...

C++ compilation error enum "does not name a type"

Hello, The following code: foo.h #include "bar.h" class foo{ public: enum my_enum_type { ONE, TWO, THREE }; foo(); ~foo() {} }; foo.cpp foo::foo() { int i = bar::MY_DEFINE; } bar.h #include "foo.h" class bar{ public: static const int MY_DEFINE = 10; foo::my_enum_type var; bar() {}; ~bar() {}; }; Mak...

c# plugin system question

so I implemented a really simple plugin system. i have the following Assemblies: MainApp IPlugin PluginApp Both MainApp and PluginApp conatin a reference to the IPlugin. Now, in MainApp I scan a plugins folder and search for things that implement the IPlugin interface. However, it is not working because both MainApp and PluginApp r...

How does PHP know what type of variables it uses (or does it)?

I haven't done much programing in many languages, but I know in C(++), you have to declare a variable type (int,char,etc). In PHP you, of course, don't have to do that. You can start with $str = "something"; then later $str = array("something" => "smells"); and she is happy. How does PHP compile? How does it know what the variable typ...

How do you generate a random double between these points?

37.807614 to 37.786996 The randomly generated double must have the same precision (num of digits) as those above. For example, 37.792242 would be good, whereas 37.7823423425 would be bad. ...

Interpret 0x string as hex in Python

I'm appending some hex bytes into a packet = [] and I want to return these hex bytes in the form of 0x__ as hex data. packet.append("2a") packet.append("19") packet.append("00") packet.append("00") packHex = [] for i in packet: packHex.append("0x"+i) #this is wrong return packHex How do I go about converting ('2a', '19', '00', ...

Haskell: I/O and Returning From a Function

Hi all, Please bear with me as I am very new to functional programming and Haskell. I am attempting to write a function in Haskell that takes a list of Integers, prints the head of said list, and then returns the tail of the list. The function needs to be of type [Integer] -> [Integer]. To give a bit of context, I am writing an inter...