FAQ Database Discussion Community
types,casting,f#,primitive
I've designed my app domain with custom F# types, but now it seems like these custom types will be a PITA when I want to actually use the data for various tasks... i.e. writing values to a CSV file, using other libraries that rely on primitives, etc. For example, I...
c++,templates,types
Just experimenting with multiple return values using this simple snippet that calculates sum and mean from a container. template<typename Iter> std::tuple<double, double> summean(Iter first1, Iter last1) { double sum = std::accumulate(first1, last1, 0.0); double mean = sum / (last1-first1); return {sum, mean}; } The demo uses double precision calculation just...
types,f#,typeerror,discriminated-union
Can anyone tell me what the following error message means in F#: Program.fs(1021,16): error FS0001: This expression was expected to have type FSI_0051.ExprTree but here has type FSI_0061.ExprTree It was the result of executing the following function: let evaluate_tree tree = let rec helper tree = match tree with |...
types,module,encapsulation,coq
Is there a way in which I can define a type inside a Coq module but encapsulate the constructors? I want a client of the module to be capable to use the type but not to construct members of that type, similar to what can be done in OCaml with...
ios,objective-c,types
I am trying to follow a tutorial for using a stylesheet from Nick Kuh's book "iPhone App Development". The stylesheet header file is throwing: "Expected a type" errors which I think normally reflects a circular problem. However, in this case the only import is to Foundation.h. (The implementation file, btw,...
php,types,floating-point,int
This question already has an answer here: Is floating point math broken? 18 answers Today my coworker stumbled on this: $s = floatval("307.03"); $s = $s * 100; echo intval($s); //30702 float value or round($s) return 30703 as expected. I guess it's a problem connected with float to int...
function,generics,types,f#
I'm confused on how to label a function as generic without an explicit type declaration like ('a -> 'a) let add a b = a + b This gives us val add : a:int -> b:int -> int However we can then immediately call add "Hello " "World!" and now...
types,count,sparql
I am trying to count the instances of each datatype in a dataset. It is a simple dataset with only three data types: integer, string and dateTime. I can get the number of datatypes (3) by querying: SELECT (COUNT(DISTINCT datatype(?o)) AS ?dTypeCount) {?s ?p ?o. FILTER (isLiteral(?o)) } GROUP BY...
haskell,types,type-signature
New guy at haskell here. I'm trying to get better at writing type signatures and this simple one doesn't want to work. I'm wondering why: average :: Num a => [a] -> a average ns = sum ns `div` length ns Average should take any number and return some number....
c#,generics,types,stream,buffer
I have a Stream where I'd like to read data from (as value type segments) and move the position according to the size of the given type (declared as generics). My current approach: public byte ReadUInt8(Stream stream) { return (byte)stream.ReadByte(); } public ushort ReadUInt16(Stream stream) { return (ushort)((ReadUInt8() << 8)...
scala,types
(Note: The motivation for this requires a long and difficult explanation; you can find the full discussion on this Accord issue. It might not even be the right solution to the problem, but I believe the question is interesting in of itself.) I'm looking a way to implement a binary...
arrays,stored-procedures,types,db2,row
I have a java front end that has a table of data. We need to save this data to the Database via stored procedure. If the passed parameter is a just an array, I am able to access the contents easily. But if the contents of the array is a...
list,haskell,types,existential-type,heterogeneous
I would like to have a heterogeneous list of String and [String], as such: strs = ["h", ["x", "y"], "i", ["m", "n", "p"]] I know I can do this with a custom data type: data EitherOr t = StringS t | StringL [t] eitherOrstrs :: [EitherOr String] eitherOrstrs = [StringS...
java,sql-server,jdbc,types,data-type-conversion
My sqlserver table has a column designed as a BIT datatype. It has values 1 and 0s Then in my Java code, I do result = new ArrayList result.add( (Boolean)(rs.getBoolean("columnName"))); Then when I read the value from the list - it shows as Long. According to everything I find, it...
types,macros,global,local,stata
I want to generate a variable with lagged year depending on the year stored in "$S_DATE" macro I have stored the year in date macro: . local date substr("$S_DATE",8,.) . display `date' 2015 And I want to generate the new variable with gen start_year =`date'- y_passed where y_passed is a...
c,types,casting
I'm changing an uint32_t to a float but without changing the actual bits. Just to be sure: I don't wan't to cast it. So float f = (float) i is the exact opposite of what I wan't to do because it changes bits. I'm going to use this to convert...
mysql,types,data-type-conversion
Is it possible, and how would I go about converting a string representation of a bit mapping such as '10010' to cast it as the integer value it represents? We are using a string built bit map for permission settings, and I need to then cast it to the integer...
list,delphi,types,delphi-2009
I want to create a list in which every element must have 3 fields: KeyType, KeyName, Value. The type of Value field should be: String, Cardinal, Integer, Byte, Boolean... depending on value of the KeyType. I need this to make something like windows registry. It is possible ?
java,types,comparison
This question already has an answer here: Why does 128==128 return false but 127==127 return true in this code? 4 answers Why equal operator works for Integer value until 128 number? [duplicate] 7 answers I know that i am comparing reference while i'm using == which is not a...
sqlite,types
I was trying to make a basket of products and i need to create a type in sqlite like: create type B_productes as object ( id_product integer, quantity integer ); Or if you can give other solution.Thanks...
ios,objective-c,memory,types,casting
I have read about __bridge, _bridge_retain and _bridge_transfer and did some experiments. However the output does not coincide with what I was expecting. In particular, I have the following code: @interface ViewController () @property (nonatomic, strong) NSString *test; @end @implementation ViewController CFStringRef cfString; - (void)viewDidLoad { [super viewDidLoad]; self.test =...
python,multidimensional-array,types
I am having a hard time with pythons uncertainties package. I have to evaluate experimental data with python, which I've been doing for a while but never encountered the following problem: >>>from uncertainties import ufloat >>>from uncertainties import unumpy as unp >>>u = ufloat(5, 1) >>>l = unp.log(u) >>>print(l) 1.61+/-0.2...
java,generics,recursion,types
I'm trying to create an implementation of Map that takes collections as keys. What do you even call this conundrum? What is the right way to do the class signature? class SubClass <K extends Collection<E>, V> implements Map<K, V> ^^ Is improper syntax, but indicates what I want to do....
.net,reflection,types
I cannot fully understand when to use one or another. They are so similar that it's confusing me every now and them. When it comes to reflection, I don't know whether to use the plain Type or TypeInfo. .NET Framework itself adds more confusion with things like assembly.DefinedTypes. It retrieves...
haskell,types
I'm just getting into my first real Haskell project of size (a web app), and I'm starting to run into issues with types from 3rd party libraries leaking all over my code. Here is a quick example: My Parser module imports Test.Parsec, and the exports a function (parseConfig) that returns...
javascript,types,ternary-operator
I was playing around with JSconsole and found something strange. The value of "0" is false "0" == false => true The value of false when used in ternary returns the second value false ? 71 : 16 => 16 However the value "0" which equals false when used in...
powershell,types
If I declare a data type like this: Add-Type -TypeDefinition "public class MyTest {}" and then create an object and get its data type, I get MyTest, as I would expect: (new-object MyTest).GetType().Name but if I refer to the type directly... [MyTest].GetType().Name I get RuntimeType. can anyone explain what's going...
types,neo4j,cypher,load-csv
is there a way to tell the neo4j the type of the value when importing? for example, does the neo4j knows if "2015-0104T10:33:44" is a date or string? thanks!...
scala,generics,types,typeclass,type-parameter
In Scala, if you create a typeclass, say the algebraic structure Monoid[T], you can provide many default typeclass implementations for different types that are monoids. Suppose a monoid is defined as: trait Monoid[T] { def op(x: T, y: T): T def id: T } Since Strings under the concatenation operation...
r,generics,types,r-s3
I try to write a function where I can throw in a abitrary number of objects and get a list of the datatypes of that objects. This is a personal task to learn S3 Generics. What I have done so far is: myTypes <- function(x, ...) { dots <- list(...)...
reflection,types,go
Under what circumstances could this code: v, ok := value.(int64) if !ok { panic("NOPE "+reflect.TypeOf(value).Kind().String()) } else { fmt.Printf("VAL: %d\n",v) } produce the panic with message panic: NOPE int64? Is this a bug or is there something basic about the numeric types that I'm missing?...
types,julia-lang,type-parameter
How does one define a type that, like Array, has a concrete/instantiated type parameter? My initial instinct was that it would be like this: immutable Foo{N::Integer} data::Array{Float64, N} end However, this generates the following error: ERROR: syntax: malformed type parameter list The following code is acceptable: immutable Foo{N} data::Array{Float64, N}...
c#,.net,types,casting
My situation: interface ISomeInterface { void DoSmth<T>(T other); } class Base : ISomeInterface { public virtual void DoSmth<T>(T other){ // for example do nothing } } class Derived<T2> : Base { Action<T2> MyAction {get;set;} public override void DoSmth<T>(T other){ if(typeof(T2).IsAssignableFrom(typeof(T))) MyAction((T2) other); } } This gives me an error: Cannot...
java,types,parametric-polymorphism,java-generics
I am in a strange situation here, namely eclipse tells me that Long is "not a valid substitute for the bounded parameter <T extends Comparable<? super T>>". Any suggestions on what may be the cause? I'm pasting relevant code below abstract Pair: public abstract class Pair<T extends Comparable<? super T>,...
haskell,types,monoids,type-variables,foldable
I'm playing around with type-aligned sequences, and in particular I'm messing around with the idea of folding them. A foldable type-aligned sequence looks something like this: class FoldableTA fm where foldMapTA :: Category h => (forall b c . a b c -> h b c) -> fm a b...
types,polymorphism,ocaml,record
type 'a item = { name:string; quantity:'a };; This is a polymorphic type definition taught in Ocaml class. I'm trying extend this type have more than one polymorphic variables in item type like: type 'a item = { name:string; quantity:'a; price:'b };; But, I'm getting an error with unbound value...
object,syntax,types,dart
I have the code if(querySelector('#username').value!="") and it is working. But Darteditor warns me, that the getter 'value' is not defined for the class 'Element'. I know, that what the querySelector returns is an InputElement and therefore, my question is only for reasons of beauty and to remove the warnings. How...
c#,reflection,types
how can I get all the types that been used in specific type? Example for class "MyClass": [MyAttribute(new OtherType(TestEnum.EnumValue1))] public class MyClass:MyOtherClass { public Type MyType { get; set; } public string MyString { get; set; } private DateTime MyDateTime; [OtherAttribute()] public int MyMethod(double doubleNumber, float floatNumber) { justMyClass myJustClass...
haskell,types,ghc,typeclass
I've been following the GHC.Generics tutorial to make a simple generic typeclass for providing default values for arbitrary types. However when I try to load my file (relevant snippet, which still produces the error) {-# LANGUAGE DefaultSignatures, DeriveGeneric, TypeOperators, FlexibleContexts #-} import GHC.Generics class Default a where def :: a...
c++,types
I found that(click here) switch can use integer types or "enumerated types" in controlling expression inC++. One explanation for "enumerate" in this article is that enumerated types "are types that are defined with a set of custom identifiers, known as enumerators, as possible values". However, for types like char,...
scala,types,type-safety
I have a graph, where each vertex has both an ID (which never changes) and a label (which changes frequently). Both are represented by longs. Currently, I define the following types: type VertexId = Long type VertexLabel = Long However, I discovered a bug today where I was passing in...
swift,types,init,lazy-initialization
I get error Unable to infer closure type in the current context In code which was working in Swift 1.2 private lazy var _messagesVC = { return MessagesViewController(nibName:"MessagesViewController",bundle:nil)}() Whole View Controller where I get this error import UIKit class FriendsViewController: UIViewController { @IBOutlet weak var containerView: UIView! @IBOutlet weak var...
haskell,types
So, I have this function: solve x y = do ... return (newx,y++[1]) where x and newx are [[Int]] and y is [Int]. And with this function, I will return a "value". Now, I would like to know how can I "process" this value in order to extract the 2...
function,haskell,types,monomorphism-restriction
It turns out that in GHC 7.10, this compiles fine: mysum xs = foldr (+) 0 xs But this: mysum = foldr (+) 0 results in the following error: No instance for (Foldable t0) arising from a use of ‘foldr’ The type variable ‘t0’ is ambiguous Relevant bindings include mysum...
java,eclipse,types,classpath,derby
I've been messing around with Apache Derby inside Eclipse. I've booted up a Network Server, and I've been working with servlets. In my Eclipse project, I have a class called "User", inside the package "base.pack". I have an SQL script open, and I've been trying to convert User, which implements...
python,dictionary,pandas,types
I have a data frame df that has >2000 columns with different datatypes. I plan to convert those non-numeric categorical variables into numerical ones. So, I need to get those column names first. col_dataType = df.columns.to_series().groupby(df.dtypes).groups col_dataType is a dictionary with these 3 values col_dataType.keys() Out: [dtype('O'), dtype('int64'), dtype('float64')] Now...
javascript,audio,types,web-audio
I'm trying to stream audio from a server containing an audio file to a client using BinaryJS. My code was inspired by the code in this question: Playing PCM stream from Web Audio API on Node.js Here's what my server code looks like: // create a BinaryServer using BinaryJS var...
java,generics,types
I would like to use a generic type to ensure, that the arguments of a method are of the same type, like this: public static <T> void x(T a, T b) I would assume that the two arguments (a and b), that are passed to this method, would always have...
types,macros,glib,gnome
I am trying to create a macro which will cast a gpointer to GType and vice versa. I have created the following macros to do this using the relevant API documentation as a guide: #ifdef GTYPE_TO_POINTER #define GTYPE_TO_POINTER (x) (GSIZE_TO_POINTER (x)) #endif #ifdef GPOINTER_TO_GTYPE #define GPOINTER_TO_GTYPE(p) (GPOINTER_TO_SIZE (p)) #endif I...
types,go,stack
I'm trying to make a stack that will store a series of Huffman Tree structs. Currently I'm using an implementation that I found on github. package util type item struct { value interface{} next *item } //Stack the implementation of stack //this stack is not thread safe! type Stack struct...
haskell,recursion,types,scheme,closures
The following procedure, written in Scheme, (define (eat xs) (lambda (x) (if (eq? x 'vomit) (reverse xs) (eat (cons x xs))))) can be called in the following way: > eat #{procedure 9165 eat} > (eat '()) #{procedure 9166 (unnamed in eat)} > ((eat '()) 1) #{procedure 9166 (unnamed in eat)}...
java,mysql,types,jtable
I have table that stores what a customer would have bought. The table is of the following format: Columns: id fullName cell items. The column items is of data type LONGTEXT. I want to store items as strings there. Under normal circumstances, the string will be represented as Text line...
c,gcc,memory,types,compiler-optimization
While coding, I try not to use more variable memory than needed and that leads me to write code like this: for (uint8 i = 0; i < 32; i++) { ... } instead of: for (int i = 0; i < 32; i++) { ... } (uint8 instead of...
java,types
I have come across this error a few times, and I try many things to fix it, but I can't seem to find out what is going wrong. here is the code: import java.util.Scanner; public class InputExample { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String...
java,generics,types
I have written a small list sorter that works by using Key objects to extract specific "keys" from objects in comparable form. The sorter then sorts the list in accordance with all the keys in turn. The sorter can sort using any set of keys that work on the given...
java,types,int
This question already has an answer here: Is Java “pass-by-reference” or “pass-by-value”? 54 answers I am learning about References and Datatypes in Java and this particular code is still confusing me. I understand that all of the primitive types in Java are value types (byte, short, int, long, float,...
java,string,types
I'm a begginner in Java and I have a question about convert String to a Class Type (?). My main class have this: Scanner scanner = new Scanner(System.in); System.out.println("Inserir 1o nome:"); String firstname = scanner.next(); System.out.println("Inserir apelido:"); String lastname = scanner.next(); System.out.println("Inserir género:"); String gender = scanner.next(); System.out.println("Inserir tipo de...
c#,generics,types,.net-4.0,value-type
I want to write method which calculate value types size. But i can't give value types (int, double, float) as method parameter. /* *When i call this method with SizeOf<int>() and *then it returns 4 bytes as result. */ public static int SizeOf<T>() where T : struct { return Marshal.SizeOf(default(T));...
java,types,javadoc
When Javadoc'ing, I don't know whether you should explicitly say whether the parameters are of type String or int. For example /** * This method does something * @param foo an object of type Foo * @param abc the number of doors, of type int * @return the number of...
algorithm,haskell,types,type-inference,type-systems
I have been implementing kadane's algorithm in haskell, AFAIK it is working correctly kadane' :: (Ord a, Num a) => [a] -> a kadane' xs = head$ foldl maxsub [0,0] xs maxsub :: (Ord a, Num a) => [a] -> a -> [a] maxsub x y | last(x)+y > head(x)...
c#,types,resharper,hierarchy,inspect
Sometimes ReSharper is kind and shows all types. Sometimes only my own types. Can't follow the logic behind this... How to force it to show all types? Tried with Navigate -> Derived Types and Inspect -> Type Hierarchies. Visual Studio 2013 ReSharper 9...
haskell,types,ghc,typeclass
I have a typing problem with a Haskell function. I implemented this (simplified) function : function (xa,ya,za) (xb,yb,zb) (Size tai) = function (xa,ya,za) (xb,yb,zb) (Ndiv ndiv) where ndiv = ceiling (leng / tai) leng = sqrt((xb-xa)**2+(yb-ya)**2+(zb-za)**2) data Method = Ndiv Int | Size Double It working well if I give...
javascript,arrays,types,type-conversion
I am trying to convert in Javascript an array A=['"age":"20"','"name":"John"','"email":"[email protected]"']; to object O={"age":"20","name":"John","email":"[email protected]"}. How I can do this. Thanks...
java,arraylist,types,erasure
public void run(){ setFont("Courier-24"); //Define list as ArrayList<Integer> ArrayList<Integer> list = new ArrayList<Integer>(); readList(list); } private void readList(ArrayList list){ list.add("Hello"); list.add(2); println("list = "+list); println("Type of list = "+list.get(0).getClass()); println("Type of list = "+list.get(1).getClass()); } Result: list = [Hello, 2] Type of list = class java.lang.String Type of list =...
arrays,matlab,types
For some reason when I try the size function in matlab, I cannot determine the datatype and cannot use it the way I want. data = [[3,4,56,1,2],[3,1,3,45,2]]; Then, I want to get the second dimension: size(data)(2) throws an error: >> size(data)(2) Error: ()-indexing must appear last in an index expression....
c#,sql-server,database,types,sqldatareader
ID = reader.GetInt16(2) //ID: ushort Will give me the error Error "Cannot implicitly convert type 'short' to 'ushort'. An explicit conversion exists (are you missing a cast?)". What is the best practice to get the data without changing my property to short?...
recursion,types,julia-lang,type-alias
I would like to create a nested tuple type, that can hold itself, or the particular type it contains. So I thought: typealias NestedTuple{T} Tuple{Union(T,NestedTuple{T}),Union(T,NestedTuple{T})} However this comes up with an error LoadError: UndefVarError: NestedTuple not defined How is this kind of typealias normally done? (I am in julia 0.4)...
javascript,node.js,types,sequelize.js
I'm using the path module in Node.js version v0.10.36. It works on my laptop in Node.js version v0.10.30. I am basically passing a string contained in an object with one of the return values from a function handled by Sequelize that fetches from a MySQL Database. If I switch out...
types,dart,jwt
I have a problem with the dart types when using the JwtSessionHandler. I wanted to integrate user authentication and sessions using this example application from the shelf_auth git repository as a guide. Unfortunately I get an error when running the application (no syntax errors are detected before running the application)...
json,haskell,types,aeson
I have a function which uses Aeson to get data from a json object within a file. The data and function are both defined below. data Data = Data { date :: String , temperature :: Int } deriving (Show, Read, Generic) data Temperatures = Temperatures { temperatures :: [Data]...
swift,types,cgfloat
I am writing a function in Swift to detect which hexagon I am clicking on. But I ran into a peculiar error message stating that I cannot add two CGFloats. Whatever I did, e.g. changing let to var, declare and assign separately, did not work. I guess there must be...
types,rust
Background: I'm using the nalgebra library and I want to create a structure that represents a multivariate normal distribution. M is the type of the matrix, e.g. Mat4<f64>. My current attempt looks like this: use std::ops::Mul; use std::marker::PhantomData; use nalgebra::*; #[allow(non_snake_case)] pub struct Multivarð©<N, V, M: SquareMat<N, V>> { μ:...
java,types
I want to do this: Foo<String> foo = new Foo<>(); Foo<String>.Bar fooBar = foo.new Bar(); fooBar.doSomething("this works!"); But then the first 2 lines in a single line like: Foo<String>.Bar fooBar2 = new Foo<>().new Bar(); fooBar2.doSomething("The above line gives: incompatible types. Required: Foo.Bar Found: Foo.Bar"); But the first line fails. I...
haskell,types,binding,dependent-type
Haskell beginner here. I've defined the following types: data Nat = Z | S Nat data Vector a n where Nil :: Vector a Z (:-) :: a -> Vector a n -> Vector a (S n) infixl 5 :- I'm trying to write the function, takeWhileVector which behaves the...
c++,types,naming-conventions
I have started using OpenCL library lately and I've noticed that they are using their own integer types, like cl_int and cl_uint instead of int and unsigned int. Why is that? Why don't they use the types that are by default in the language? Is it a good practice or...
c++,arrays,types,iterator,declaration
I can iterate through a C-style array this way: char foo[3] = { 'a', 'b', 'c' }; for (auto it = std::begin(foo); it != std::end(foo); ++it) { *it = 'k'; //values of foo are correctly modified } Now suppose I want to wrap the array inside a class, and expose...
c#,memory-management,types,type-conversion,dllimport
I'd like to interpret the output of the following unmanaged function: afc_error_t afc_get_device_info (afc_client_t client, char ***device_information) I import the dll with the code: [DllImport("libimobiledevice.dll", CallingConvention = CallingConvention.Cdecl)] internal static extern short afc_get_device_info(IntPtr client, out IntPtr info); As long as I only needed to convert response to string Marshal.PtrToStringAnsi was...
c++,dll,types,loadlibrary
I have one line in my C++ program HINSTANCE hInstLibrary = LoadLibrary("DLL_tut.dll"); Here I'm getting error saying that error C2664: 'LoadLibraryW' : cannot convert parameter 1 from 'const char [12]' to 'LPCWSTR' I'm trying to implement program given in link http://www.codeguru.com/cpp/cpp/cpp_mfc/tutorials/article.php/c9855/DLL-Tutorial-For-Beginners.htm Tried finding some solutions and found this one closest...
types,mapping,logstash,kibana,grok
Doesn't matter if integer/long or float, fields like time_duration (all time_* really ) map as strings in kibana logstash index. I tried using mutate (https://www.elastic.co/blog/little-logstash-lessons-part-using-grok-mutate-type-data) did not work either. How can i correctly enforce numeric type instead of strings on these fields? My /etc/logstash/conf.d/haproxy.conf: input { syslog { type =>...
c++,c,pointers,types,casting
I have: const char *ptr = "int"; If I have to declare using ptr: int a; ptr can point to anything arbitrary char, string, <anythihg>. I have to delcare a variable of that type what ptr is pointing at. Is it possible?...
haskell,types
I've started learning Haskell and got problems. I try to understand lambda and created function mo06 mo06 f x = if f x then x else x * x I can call that in ghci: λ mo06 (== 1) 1 1 λ mo06 (== 1) 3 9 That works ok...
linq,types,iqueryable
I have an iQueryable dataset. I wish to be able to determine the type of data based on the name. I am doing a linq query into a view model and I wish to get the type of column by name from the resulting query...
python,python-3.x,types
This question already has an answer here: Differences between isinstance() and type() in python 5 answers I was looking at some code on the web, and I saw some code I'm not used to. The one that most called my attention was: if not isinstance(string, str): #dosomething What would...
debugging,generics,types,compiler-errors
"Generics add stability to your code by making more of your bugs detectable at compile time." I keep reading this everywhere, but I can't seem to find an explanation for why generics help make errors more detectable in compile time rather then run time. Maybe this might be answered somewhere...
types,typescript,typescript1.4
I have the following classes: export interface ISimpleUser { id: number; full_name: string; } export interface IMember extends ng.resource.IResource<IMember> { id: number; project: number; user: number|ISimpleUser; skills: ISkill[]; about: string; accepted: Boolean; updated: Date; created: Date; } At some point I want to iterate over an arroy of members like...
c,haskell,types,ffi,hsc2hs
I am trying to write a Haskell program that communicates with C (ultimately for iOS via GHC-iOS). I want it to pass a string from C to Haskell, have Haskell process it and then return some Data types from Haskell to C Structs via hsc2s. I have been unsuccessful at...
python,django,types
When I am creating a HttpResponse object, should I pass it a integer for the status_code attribute, or a string? I.e. HttpResponse('401 Client Error', status=401) vs. HttpResponse('401 Client Error', status="401") The documentation is a generic descriptor, that doesn't give the type. HttpResponse.status_code The HTTP status code for the response. ...
indexing,types,integer,type-conversion,ada
I have an array of some kind of objects, indexed by a type index: type index is new Integer range 1..50; type table is new Array(index) of expression; Now, I need to access one of these expressions, depending on a user entry by keyboard. For that I do following: c:...
c++,types,const
Consider the code: int const x = 50; int const& y = x; cout << std::is_const<decltype(x)>::value << endl; // 1 cout << std::is_const<decltype(y)>::value << endl; // 0 This makes sense, because y is not a const reference, it is a reference to a const. Is there a foo such that...
haskell,types
I have a problem relating to the Haskell type system. This is not the first time I have encountered the type system's limitations. I will omit my project details and use a simplified example. Here is some code: -- Works foo :: (Bounded a, Enum a) => a foo =...
mysql,sql,types,go,custom-type
Having this table structure: CREATE TABLE `tableName` ( `Id` int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY, `Status` enum('pending','rejected','sent','invalid') NOT NULL, `Body` varchar(255) NULL ) ENGINE='MyISAM' COLLATE 'utf8_general_ci'; I have this (not complete) code working fine: type StatusEnum string const ( STATUS_PENDING StatusEnum = "pending" STATUS_REJECTED StatusEnum = "rejected" STATUS_SENT StatusEnum...
class,haskell,opengl,types,uniform
I'm working on making my data types general instead of taking in the OpenGL type GLfloat. So I started making it take in type a and then just replacing everything with that. Now, I've come to a point where I'm setting uniform variables, but they take in GLfloat's. I'm using...
collections,types,drools,rules,declare
Here is what I have in my DLR file: package mytypes; declare Person firstName : String lastName : String address : java.util.ArrayList end declare Address city : String state : String end rule "city" when p : Person() Address(city == "Dallas") from p.address then System.out.println("city rule fired"); end I use...
java,syntax,types,resolve
With help I got the program to run and answer the questions but it does not show the tuition total. Thanks for reading. Stackoverflow says I need to post more details so I am just typing for the details. import java.util.Scanner; public class Student { private static String FirstName; private...
scala,generics,types,implicit-conversion
I'm learning Scala by working the exercises from the book "Scala for the Impatient". One question asks: Given a mutable Pair[S, T] class, use a type constraint to define a swap method that can be called if the type parameters are the same. My code: class Pair[T, S](var first: T,...
haskell,types,ghci
In GHCi, i type let xs = [1, 'a'] it complains the error immediately: <interactive>:28:11: No instance for (Num Char) arising from the literal ‘1’ In the expression: 1 In the expression: [1, 'a'] In an equation for ‘xs’: xs = [1, 'a'] However, when I type let xs =...
c,pointers,types,pointer-arithmetic
This question already has an answer here: If you add 1 to a pointer, does it really add 1, or does it add 4 or 32? [duplicate] 2 answers I know that on incrementing a pointer variable it points to the next location of it's type i.e. int main()...
scala,haskell,types,ocaml
Now when we have these fancy type-systems to prevent null-pointer bugs and memory bugs and all, what common bugs are left? Can these bugs be prevented with different type-systems or further programming language research? Edit: Do we know what bugs are common in functional programming? Edit 2: -3 question with...
c,arrays,types,shift
How do we convert 8 byte char array into long since << does not work for type long? #define word_size 8 long num = 0; char a[word_size] = "\x88\x99\xaa\x0bb\xcc\xdd\xee\xff"; for (i=0; i < word_size;i++) { a[(word_size-1) - i] |= (num << (8*(word_size - i - 1))) & 0xFF; } printf("%lx\n",...
c++,c,types,grammar
I notice that this is a valid prototype while reading through the ANSI C grammar spec from 1985 published by Jeff Lee and I compiled a function with this signature. What exactly might a function with this prototype return? What would a simple body of this function look like?