Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Algebraic Data Type



  What the Heck are Algebraic Data Types? ( for Programmers )

This post is meant to be a gentle introduction to Algebraic Data Types. Some of you may be asking why you should learn Algebraic Data Types and how will they change your world?  I am not going to answer that, but suffice it to say that Algebraic Data Types are the underpinning of the type systems to the ML derived languages, Haskell and OCaml included, and their construction and properties allow for the power (and inference) that accompanies these type systems.  They are cropping...

   Algebraic Data Type,Set,Operator,Programmer     2011-12-30 08:31:43

  Haskell’s effect on my C++: exploit the type system

Like most programmers, I was attracted to Scheme by the promise that it would make me a better programmer. I came to appreciate the functional style, but swapped to Haskell, a more developed language with a rapidly developing standard library. Unfortunately, for me, Haskell can’t yet replace C++ on a day to day basis, so I reluctantly spend my days tapping away at C++. So, were the promises true? has functional programming made me a better programmer? Better is a tough question,...

   Haskell,C++,Type system,Comparison     2012-02-06 07:44:35

  Introduction to GoLang generics and advanced usage

Generics in Go allow you to write code that can work with multiple types of data, without having to write separate versions of the code for each type. This can make your code more flexible and easier to maintain, as you only need to write and test the code once, rather than maintaining multiple versions. To use generics in Go, you first need to define a type parameter, which is a placeholder for the type that the code will work with. For example, you might define a type parameter called "T" like...

   GOLANG,GENERICS     2022-12-17 05:12:21

  Data type in MySQL

For both small free database space and large e-commerce websites, reasonable database table structure design is essential. To achieve this, it requires us to have a full understanding of commonly used data types in database system. Below we share some knowledge about data types in MySQL.1. Numeric typesThe numeric types can be classified as : integer, float and decimal type.The so-called "decimal" refers DECIMAL and NUMERIC, they are of the same type. Strictly speaking it is not a numeric type, ...

   MySQL, Data type,VARCHAR     2013-01-01 10:56:06

  Time to think about supporting max/min functions for integers in GoLang

Sometime back we wrote a post explaining why there is no max/min function support for integers in GoLang, one of the reasons is that no overloading is supported and the function name has been used for other numeric types float64. To solve this problem and make max/min function support integer as well, either GoLang should support overloading like in Java or the same set of functions need to be created in a different package other than standard math. These don't look like good options as overload...

   MIN,MAX,GENERICS,GOLANG     2021-07-24 03:14:42

  Removing duplicates in sql

In modern web development, it’s standard practice to make use of a database abstraction layer, typically an Object-Relational Mapper based on either the Active Record pattern or the Data Mapper pattern. There are several pros and cons to this which are fairly well established, so I’ll spare us all from enumerating them all right now. One established pro worth mentioning is that these systems typically provide a high level interface for fetching data, often removing the need to ...

   SQL,Duplicate,Remove,Web design     2012-01-05 08:20:13

  How to optimize MySQL insert statement

For a big data system, one problem is the data access efficiency, one more problem is that the data insertion is very slow. We had a service system, the data loading process would take 4-5 hours. This time consuming operation is risky since if the program is interrupted during the loading process, it might be rerun, this will be troublesome. So it's necessary to improve the insertion efficiency for big data systems. Here we provide two optimization suggestions. 1. Combine multiple insert stateme...

   MySQL,insert,optimization     2012-10-24 22:03:13

  Empty slice vs nil slice in GoLang

In Go, there is a type called slice which is built on top of array. It's a very convenient type when we want to handle a group of data. This post will explain a subtle but tricky difference between empty slice and nil slice. A nil slice is a slice has a length and capacity of zero and has no underlying array. The zero value of slice is nil. If a slice is declared like below, it is a nil slice. package main import "fmt" func main() { var a []string fmt.Println(a == nil) } The output will be t...

   GOLANG,JSON,EMPTY SLICE,NIL SLICE     2018-10-18 09:25:21

  How to check whether a struct implements an interface in GoLang

Unlike other programming languages like Java, when implementing an interface in GoLang, there is no syntax like below to explicit tell the relationship: type I interface { } type A struct implements I { } When looking at the code or running the code in GoLang, it might lead to a case one doesn't know whether a struct implements interface before trying to use it as some interface. According to GoLang spec, as long as a struct implements all functions of an interface, it is considered as having i...

   GOLANG,INTERFACE,IMPLEMENTATION,CHECK     2020-05-03 00:05:54

  Can a == true && a == false be true in JavaScript?

JavaScript is a weak typed language and it has a loose comparison feature where two objects/values of different type can be compared using == operator. This provides developers great flexibility and confusion at the same time.  Before understanding how == works in JavaScript, can you first answer the question in the post title? Can a == true && a == false be true in JavaScript? Normally, we would think that this expression will always return false since a can be either true or ...

   JAVASCRIPT,COMPARISON,INTERVIEW QUESTION,==     2018-03-25 03:39:43