language-comparisons

Type classes in Scala

别说谁变了你拦得住时间么 提交于 2019-12-03 07:26:34
问题 Having a background in Haskell I am currently trying to get familiar with Scala. I encountered some problems trying to translate a small, extensible expression language from Haskell into Scala. The underlying issue of writing a data type that is extensible with both new data-variants and operations is commonly known as the expression problem. My original solution in Haskell uses type classes and instance declarations with constraints. The base of my expression is defined as follows: module

Implementing python slice notation

南楼画角 提交于 2019-12-03 05:54:05
I'm trying to reimplement python slice notation in another language (php) and looking for a snippet (in any language or pseudocode) that would mimic the python logic. That is, given a list and a triple (start, stop, step) or a part thereof, determine correct values or defaults for all parameters and return a slice as a new list. I tried looking into the source . That code is far beyond my c skills, but I can't help but agree with the comment saying: /* this is harder to get right than you might think */ Also, if something like this is already done, pointers will be greatly appreciated. This is

Groovy advantages over Jython or Jruby?

感情迁移 提交于 2019-12-03 01:41:15
问题 Why would I choose to use Groovy when I could use Jython or Jruby? Does the language provide any inherent advantages to make up for the fact that Jython and Jruby skills are applicable to their parent languages outside of the JVM? Keep in mind that I purposely keeping this question generic, but if there are any advantages that exist in a particular domain, please don't hesitate to describe them. EDIT To clarify, If I write some code in Jruby, I can now, in some cases, move that code outside

Type classes in Scala

社会主义新天地 提交于 2019-12-02 22:19:42
Having a background in Haskell I am currently trying to get familiar with Scala. I encountered some problems trying to translate a small, extensible expression language from Haskell into Scala. The underlying issue of writing a data type that is extensible with both new data-variants and operations is commonly known as the expression problem . My original solution in Haskell uses type classes and instance declarations with constraints. The base of my expression is defined as follows: module Expr where class Expr e where eval :: e -> Integer data Lit = Lit Integer instance Expr Lit where eval

Actionscript 3 vs Haxe: Which to chose for new Flash project?

徘徊边缘 提交于 2019-12-02 17:09:37
I am in the planning stages of a new Flash game project and was wondering which language would be better to use? I already have a strong understanding of Actionscript 3, and have not worked with Haxe yet, but I have read the language reference docs and it seems that Haxe has some of the features from my other favorite languages, C# and Ruby. So my question has two parts: 1) Can Haxe interop with flash components (swc files)? Like for instance if i use the Flash IDE to skin some controls, can i import those controls and use them in Haxe? 2) Are there any performance benefits to the Haxe

Haskell, Lisp, and verbosity [closed]

本秂侑毒 提交于 2019-12-02 13:55:30
For those of you experienced in both Haskell and some flavor of Lisp, I'm curious how "pleasant" (to use a horrid term) it is to write code in Haskell vs. Lisp. Some background: I'm learning Haskell now, having earlier worked with Scheme and CL (and a little foray into Clojure). Traditionally, you could consider me a fan of dynamic languages for the succinctness and rapidity they provide. I quickly fell in love with Lisp macros, as it gave me yet another way to avoid verbosity and boilerplate. I'm finding Haskell incredibly interesting, as it's introducing me to ways of coding I didn't know

Java-like Collections in PHP

老子叫甜甜 提交于 2019-11-30 17:17:32
I'm learning PHP5 (last time I checked PHP was in PHP4 days) and I'm glad to see that PHP5 OO is more Java-alike than the PHP4 one but there's still an issue that makes me feel quite unconfortable because of my Java background : ARRAYS. I'm reading "Proffesional PHP6" (Wrox) and It shows its own Collection implementation. I've found other clases like the one in http://aheimlich.dreamhosters.com/generic-collections/Collection.phps based on SPL. I've also found that there's some kind of Collection in SPL (ArrayObject) However, I'm surprised because I don't really see people using Collections in

Verbally format a number in Python

别说谁变了你拦得住时间么 提交于 2019-11-30 16:57:25
问题 How do pythonistas print a number as words, like the equivalent of the Common Lisp code: [3]> (format t "~r" 1e25) nine septillion, nine hundred and ninety-nine sextillion, nine hundred and ninety-nine quintillion, seven hundred and seventy-eight quadrillion, one hundred and ninety-six trillion, three hundred and eight billion, three hundred and sixty-one million, two hundred and sixteen thousand 回答1: no in python core, but there is 3rd party library num2words >>> from num2words import

What is C# equivalent of <map> in C++? [duplicate]

廉价感情. 提交于 2019-11-30 07:45:19
问题 This question already has answers here : C# equivalent of C++ map<string,double> (8 answers) Closed 5 years ago . I have defined a class myComplex. I need to map it to integers. In C++ I would have created a map as map<myComplex,int> first; How to do such thing in C#? 回答1: The equivalent would be class SortedDictionary<TKey, TValue> in the System.Collections.Generic namespace. If you don't care about the order the class Dictionary<TKey, TValue> in the System.Collections.Generic namespace

is there an virtual environment for node.js?

我是研究僧i 提交于 2019-11-30 06:09:23
问题 I've searched the wiki modules page, but I can't find anything similar to virtualenv (python) or rvm. Anyone here separates node.js in their own env? I really don't like to install npm system-wide. 回答1: If having system wide npm packages is your main issue, then maybe consider using the very cool 'bundle' command with npm. This is closer to freezing gems or using bundler in rails, rather than rvm. It's super easy. Just create a package.json file: { "name": "yourapp", "version": "0.0.1",