How does a "case" anonymous function really work in Scala?

what is anonymous function in scala

what is anonymous function in scala - win

Proposal: Compound statement expressions, complex comprehensions, and assignment functions

I'd like to make the rather drastic proposal below on the python-ideas mailing list. To give it the best chance of success, I'm posting it here first for anyone willing to give feedback :)
This is a proposal to allow certain multiline compound statements to be usable as expressions and to reform certain constructs such as lambda and list comprehensions. It's inspired by other modern languages where these ideas are common and the line between statement and expression is sometimes blurry, such as Ruby, Scala, and Kotlin.
I know that similar (sometimes identical) ideas have been discussed to death before, so I apologise for bringing this up again. I have made note of some previous objections and have tried very hard to be thorough and think through all the possible consequences.
Theoretically this could be broken down into at least 5 separate proposals, but there is a lot of overlap between them so I have chosen to present them all at once. If this is a problem, I'm happy to hear suggestions on how to separate the discussions.

Examples

Here are some simple examples of the proposed new syntaxes:
Instead of:
if c1: z = foo(bar) x = y1 + z elif c2: x = y2 else: x = y3 
one may write:
x = ( if c1: z = foo(bar) y1 + z elif c2: y2 else: y3 ) 
Instead of:
try: x = f() except ValueError: x = default1 except IndexError: x = default2 foo(x) 
one may write:
foo( try: f() except ValueError: default1 except IndexError: default2 ) 
Instead of:
sorted(lst, key=lambda t: t[0]) 
one may write:
sorted(lst, key=def (t):= t[0]) 
What's going on above is that:
Instead of:
def key(x): # complex logic return y sorted(lst, key=key) 
one may write:
sorted(lst, key= def key(t):= # complex logic y ) 
This is pretty similar to the last example. Key points:
Instead of:
[ f(x) for y in z for x in y if g(x) ] 
one may write:
[ for y in z: for x in y: if g(x): f(x) ] 
Instead of:
lst = [] for x in y: if cond(x): break z = f(x) lst.append(z * 2) 
one may write:
lst = [ for x in y: if cond(x): break z = f(x) yield z * 2 ] 
Instead of:
[ {k: v for k, v in foo} for foo in bar ] 
one may write:
[ for foo in bar: {for k, v in foo: k: v} ] 

Specification

New expressions from compound statements

The value of a list of statements (a body) is the value of the last statement, or no value if the last statement is not an expression. This is determined at compile time.
The value of an if/elif/else or a try/except/else is the value of the body of the last clause that executes. If the body of one of the clauses has no value, the compound statement containing the clause cannot be used as an expression, and attempting to do so is a SyntaxError, even if some other clauses have values.
An if[/elif] with no else doesn't have a value.
A try with a finally doesn't have a value.
A function definition (def) is an expression which evaluates to the function object. The function name is optional. Parentheses around parameters are still required, particularly because otherwise def foo: could mean either def foo(): or def (foo): (an anonymous function with one parameter foo).
An if, try, or def used as an expression shall here be called a compound statement expression, or CSE for short.

Whitespace

If all bodies of a CSE consist of just one expression, then we call this an inline CSE, because it can be inserted in the same line(s) as other code and there are fewer concerns about whitespace and disambiguation. The beginning of the CSE is clearly marked by a keyword, while the end would be determined by the same logic which determines the end of the current conditional expressions x if C else y or the body of a lambda.
If the body of an inline CSE is also a CSE, the inner CSE must also be an inline CSE. Put differently, all our current expressions are inline expressions, and a CSE is also an inline expression if all of its bodies are inline expressions. Perhaps we should require that inner inline CSEs must have parentheses, e.g:
foo = if C: (if D: x else: y) else: z 
If at least one body of a CSE has multiple statements or contains a non-expression statement, then it is not inline. The CSE must start and end with a newline, i.e. the lines containing the CSE cannot contain any tokens from outside. For example, this is allowed:
foo = bar( if C: x else: y ) 
but this is not:
foo = bar(if C: x else: y) 
This means that if you wanted to add more arguments after in a function or a list literal, the comma must be on the next line. Since this looks weird:
foo = bar( if C: x else: y , spam, ) 
one might instead format it as:
foo = bar( ( if C: x else: y ), spam, ) 
which is also a bit clunky but I think that's OK because it's a gentle deterrent from abusing this syntax and putting too much information in one expression.
This restriction ensures that it's easy to copy paste entire lines to move them around, whereas refactoring the invalid example above without specific tools would be annoying and error-prone. It also makes it easy to adjust code outside the CSE (e.g. rename foo to something longer) without messing up indentation and alignment.
The first line after the end of a non-inline CSE must be less indented than the bodies of the CSE. For example, this:
x = \ if y: 1 else: 2 + 3 
is the same as
x = ( if y: 1 else: 2 ) + 3 
whereas
x = \ if y: 1 else: 2 + 3 
means that the else has two statements 2 and + 3.
These rules should help keep code readable at a glance and resolve questions about how statements embedded in expressions are disambiguated, for both humans and parsers.
Inside a non-inline CSE, the rules for indentation and such are the same as anywhere else. The syntax of the CSE is valid if and only if it's also valid as a normal statement outside any expression.

Assignment functions

An assignment function is a function which starts with := instead of : and which automatically returns the value of its body, unless it encounters an explict return earlier on. If the body has no value, it's a syntax error.
Implicit returns like this are quite popular in other modern programming languages. I've seen someone forgetting to return from a function as they were still adjusting to Python after years of Ruby. In this case I've copied the name and semantics from Coconut, a language which extends Python with functional programming syntax.
The := could instead be ->, =>, ::, etc. Coconut just uses =. The point is just to distinguish from regular functions so that existing functions don't start returning new values.
Note that def as an expression is a distinct concept from assignment functions. It's the combination of them that makes for a decent alternative to lambda, but you could also just use a def with an explicit return.

New style of comprehensions

A list/set/dict comprehension or generator expression is written as the appropriate brackets containing any number of statements including at least one for or while loop.
In the general case the body looks like a generator function, and the elements (e.g. of the list) are the yielded values.
If the comprehension contains exactly one expression statement at any level of nesting, i.e. if there is only one place where a yield can be placed at the start of a statement, then yield is not required and the expression is implicitly yielded. In particular this means that any existing comprehension translated into the new style doesn't require yield.
If the comprehension doesn't contain exactly one expression statement and doesn't contain a yield, it's a SyntaxError.
For dictionary comprehensions, a key: value pair is allowed as its own pseudo-statement or in a yield. It's not a real expression. If needed, maybe we'll require surrounding the pair in parentheses or just use a 2-tuple instead.
New style comprehensions follow the same rules as CSEs regarding whitespace. Since a loop on its own is not an expression, comprehensions with nested loops must be spread across multiple lines.

Benefits/comparison to current methods

Uniform syntax

This replaces existing syntactical constructs that were each somewhat ad-hoc solutions with expressions that mimic existing syntax:
In general the lack of additional syntactic constructs should make it easier for beginners to learn the language. For example a lambda involves a new dedicated keyword, lack of parentheses, an implicit return, and the restriction to a single expression. A def expression can be cut and pasted verbatim.
A particular concept that's easier to learn is comprehensions that contain multiple loops. Consider this comprehension over a nested list:
[ f(cell) for row in matrix for cell in row ] 
It's easy for an experienced Python coder to write this, but for beginners it can easily be confusing. Yes there's a rule that they can learn, but putting it in reverse also seems logical, perhaps even more so:
[ f(cell) for cell in row for row in matrix ] 
Now the comprehension is 'consistently backwards', it reads more like English, and the usage of cell is right next to its definition. But of course that order is wrong...unless we want a nested list comprehension that produces a new nested list:
[ [ f(cell) for cell in row ] for row in matrix ] 
Again, it's not hard for an experienced coder to understand this, but for a beginner grappling with new concepts this is not great. Now consider how the same two comprehensions would be written in the new syntax:
[ for row in matrix: for cell in row: f(cell) ] [ for row in matrix: [ for cell in row: f(cell) ] ] 

No restriction to a single expression

The current constructs can only contain one expression in their 'bodies'. This restriction makes it difficult to solve certain problems elegantly and creates an uncomfortable grey area where it's hard to decide between squeezing maybe a bit too much into an expression or doing things 'manually'. This can lead to analysis paralysis and disagreements between coders and reviewers. For example, which of the following is the best?
clean = [ line.strip() for line in lines if line.strip() ] stripped = [line.strip() for line in lines] clean = [line for line in stripped if line] clean = list(filter(None, map(str.strip, lines))) clean = [] for line in lines: line = line.strip() if line: clean.append(line) def clean_lines(): for line in lines: line = line.strip() if line: yield line clean = list(clean_lines()) 
You probably have a favourite, but it's very subjective and this kind of problem requires judgement depending on the situation. For example, I'd choose the first version in this case, but a different version if I had to worry about duplicating something more complex or expensive than .strip(). And again, there's an awkward sweet spot where it's hard to decide whether I care enough about the duplication.
Even more annoying is when I've already written a list comprehension but a new requirement forces me to change it to, say, the .append version. It's a tedious refactoring and leaves me with a completely unhelpful git diff.
What about assignment expressions? We could do this:
clean = [ stripped for line in lines if (stripped := line.strip()) ] 
Like the nested loops, this is tricky to parse without experience. The execution order can be confusing and the variable is used away from where it's defined. Even if you like it, there can be no doubt that it's controversial. I think the fact that assignment expressions were a desired feature despite being so controversial is a symptom of this problem. It's the kind of thing that happens when we're stuck with the limitations of a single expression.
The solution with the new syntax is:
clean = [ for line in lines: stripped = line.strip() if stripped: stripped ] 
or if you'd like to use an assignment expression:
clean = [ for line in lines: if stripped := line.strip(): stripped ] 
I think both of these look great and are easily better than any of the other options. And I think it would be the clear winner in any similar situation - no careful judgement needed. This would become the one (and only one) obvious way to do it. The new syntax has the elegance of list comprehensions and the flexibility of multiple statements. It's completely scalable and works equally well from the simplest comprehension to big complicated constructions. I can easily add logic as I please and get a nice simple diff.

Support in previous PEPs

The syntax if C: x else: y was AFAICT the generally preferred syntax for conditional expressions in PEP 308 before Guido chose the current syntax instead.
PEP 463 -- Exception-catching expressions proposed allowing expressions like:
value = (lst[2] except IndexError: "No value") 
This was rejected, but clearly there was some demand and I think it would have been a nice feature. Perhaps try could be made similarly optional in simple inline expressions.

Compatibility

I believe this proposal has the following properties:
submitted by alexmojaki to Python [link] [comments]

Java vs Kotlin: know which one is better to choose

Java Assignment Help experts will explain to you Java vs Kotlin in a better way.
If you are a mobile app developer, Java is probably your language for building Android apps. But new languages ​​are popping up everywhere that might challenge Java’s dominance in the Android world.
One of them is Kotlin, a relatively new programming language, already announced by Google as a “first-class” language supported on Android.
Although it is continually meaning evolved and enhanced, Kotlin is now viewing a mature ecosystem and its demand is growing quickly, especially on the mobile development scene.
Now, you will better understand about Java Vs Kotlin.

In Java vs Kotlin experts will explain Java to Kotlin story

Kotlin v1.0 was published only on 15, February 2016, the history of this programming language defines back to 2011. JetBrains founded Kotlin for their practical needs.
The company had 70% of its outputs build on Java but began to understand its shortcomings – mainly unnecessary wordiness.
They wanted a programming language that would be Java-compatible since rewriting everything into a new programming language appeared as a no-go option. Everybody started experimenting with Scala but were not fulfilled. That is when the concept of a new programming language, Kotlin, was born.

Java vs Kotlin

To know the differences between Java vs Kotlin, primarily, we determined to discuss a few about each language. We will begin with Java, and you will know its benefits, drawbacks and also what we can do with this language.
Next, we will converse about Kotlin, so that this language assists, benefits, limitations and what we can build? Finally, it will be great to get the key variations and benefits of Java vs Kotlin.

What is Java?

Java is a programming language created by James Gosling. We can create any type of program, it also supports almost any type of machine. It’s also for mobile in Linux operating system, Windows and Android.
Currently, Java has the most important and largest community in the world. In both the Internet and the computer field, this language is very important. Java can be used to do almost anything.
It should be considered that Java is completely free and can be used by anyone in the world. In this way, Java is a safe, powerful and universal programming language.

What can we program?

If you are an unimaginable programmer, you can perform anything with Java. With the most helpful websites, applications for Android, and among other things.
Second, if you are a novice on the subject of programming in Java, there is no difficulty because you can start with a simple hello world, and then become a programmer to change this world.

Pros of Java

Cons of Java

Future Scope in Java

As a career for Java developers/programmers, anyone can consider the following job roles.

What is Kotlin?

Kotlin is a new programming language of JetBrains. It first surfaced in 2011. “Kotlin” named his project was unveiled. Kotlin is an open-source language.
Basically like Java, C, and C++ – Kotlin too. But it is different from Java. Here our experts will help you to tell about Java vs Kotlin.
“Statically Typed Programming Languages” (is. Legally typed programming languages are languages that do not need to be defined before using variables. This means that static typing has to be done with a clear declaration or initialization of variables before they are planned.
Java was earlier said to be an example of a statically typed language, similarly, C and C++ are also statically typed languages.
Static typing does not mean that we have to use all the variables before declaring them. Variables in the program can be initialized anywhere and we (developers) need to do so anywhere in the program to use those variables.

Consider the following example of Java vs Kotlin

/* Java Code */
static int num1, num2; //explicit declaration
num1 = 10; //use the variables anywhere
num2 = 20;
/* Kotlin Code*/
val a: Int
val b: Int
a = 10
b = 20
In addition to the classes and methods of object-oriented programming, Kotlin also supports procedural programming with the use of functions.
Like Java, C and C++, the entry point of the Kotlin program “The main A function named “. Basically, it passed an array containing any command-line logic.

Consider the following example of Java vs Kotlin

/* Kotlin Programming*/
/* Hello Word Example*/
package hello //optional package header
fun main(args: Array < String > ) { //The function package level, which returns the unit and takes an array of strings as parameters
val scope = “world”
println(“Hello, $scope!”) //Semicolons are optional, have you seen
}
Filename extensions of the Java are .java, .class, .jar but on the other hand filename extensions of the Kotlin are .kt and .kts.

What can we create?

With Kotlin we can make many things, whichever comes to mind. Some of the projects that are built-in Kotlin are Pinterest, Flipboard, Square, etc.

Pros of Kotlin

Cons of Kotlin

Difference Between Java vs Kotlin

Null Safety

As mentioned earlier, Kotlin avoids NullPointerException. Whenever NullPointerException can be thrown, Kotlin fails at compile-time.

Data Classes

Kotlin consists of boilerplate data classes, hashcodes, tostring, getters/setters and much more such as boilerplates lead to autogeneration.

Consider the following example of Java vs Kotlin

/* Java programming */
class Book {
private String title;
private Author author;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Author getAuthor() {
return author;
}
public void setAuthor(Author author) {
this.author = author;
}
}
But the above one class in Kotlin may be briefly defined in a row
/* kotlin programming */
data class Book(var title: String,
var author: Author)
It will also allow us to easily make copies of data classes with the help of copy()
val book = Book(“Kotlin”, “JetBrains”)
val copy = book.copy()

Extension Functions

Kotlin allows us to expand the functionality of existing classes without having inherited from them. That is to say, Kotlin provides the ability to extend a class with new functionality without inheriting from the class.
This is done by expansion works. To declare an extension function, we have to prefix its name with a receiver type, that is. The type is being increased.
The following adds a swap function to MutableList
fun MutableList < Int > .swap(index1: Int, index2: Int) {
val tmp = this[index1]
this[index1] = this[index2]
this[index2] = tmp
}
The ‘this’ keyword inside the extension function belongs to the receiver object, which is passed before the dot.
Now we can call such a function on any MutableList
val abc = mutableListOf(1, 2, 3)
abc.swap(0, 2)

Smart Casts

When it comes to casts, the Kotlin compiler is intelligent. In many cases, one does not need to use the cast operators of clear in Kotlin, but for irreversible values in Kotlin and inserts casts become required automatically
fun demo(x: Any) {
if (x is String) {
print(x.length) // x is automatically cast to string
}
}

Type Inference

In Kotlin, a great thing is that you don’t need to explicitly specify the type of each variable (clearly and in a detailed manner). But if you want to explicitly define the data type, you can do the same.

Consider the following example of Java vs Kotlin

/* not explicitly defined */
fun main(args: Array < String > ) {
val text = 10
println(text)
}
/* explicitly defined */
fun main(args: Array < String > ) {
val text: Int = 10
println(text)
}

Functional Programming

The main important thing is that Kotlin is a functional programming language. Originally Kotlin includes several useful methods, including high-order tasks, long-rate expressions, operator overloading, lazy valuations, operator overloading and much more.
Functional programming makes Kotlin much more useful when it comes to collections–
fun main(args: Array < String > ) {
val numbers = arrayListOf(15, -5, 11, -39)
val nonNegativeNumbers = numbers.filter {
it >= 0
}
println(nonNegativeNumbers)
}
Output – 15, 11
High – Command tasks are functions that act as a parameter and also return a function.

Consider the following code of Java vs Kotlin

fun alphaNum (func: () -> unit){}
In the code above, The name of the parameter “func” is the name of the parameter and the name of the parameter is “() -> Unit the function type. In this case, we are saying that func will be a function that does not achieve any parameters as well as does not return any value.
Lambda expression or an anonymous function is a “Literal function, that is, a function that is not declared, but passed as an expression.
val sum: (Int, Int) – > Int = {
x,
y – > x + y
}
In the above example, we declare only the variable ‘total’ that takes two integers and adds them together and returns as an integer.
Then we use ‘sum(2,2)’ to call it.
An anonymous function is a function that allows us to specify the return type and the function name is omitted in it.

Consider the following example of Java vs Kotlin

Either this way –
fun(x: Int, y: Int): Int = x + y
or This Way
fun(x: Int, y: int): Int {
return a + b
}
submitted by Programming-Help to Programming_Languages [link] [comments]

Groestlcoin's Electrifying December 2019 Releases & Development Update

Groestlcoin brings the Lightning Network to the masses

https://www.youtube.com/watch?v=lFOvBhlAyJw&feature=share
Groestlcoin has been on an emotional journey spanning 5 and a half years now and since being the first cryptocurrency to successfully activate SegWit, the developers have been hard at work bringing as much choice as possible to the options provided for utilising SegWit. Today brings another chapter to this story as every mainstream implementation of the Lightning Network has been ported to Groestlcoin. Groestlcoin has not been focused on a single implementation but instead has ported Éclair, LND, and C-Lightning to bring the users the greatest choice.
Although extremely promising, the lightning network is still highly experimental so as a result, all channels are currently limited to 0.16 GRS per channel. The limit will be removed in the future once the system is proven stable enough. Additionally, there are also test-net versions of all implementations. Currently, Eclair is currently the most user-friendly so it will likely reach the most adoption among Groestlcoin users with LND and c-lightning being for more advanced users.
We are now announcing the greatest release we have ever done in terms of technological advancements and the sheer quantity of released technologies.

Groestlcoin Eclair

Groestlcoin Eclair is a Scala implementation of the Lightning Network. It can run with or without a GUI and includes a JSON API.

Requirements

Features

Download

Server Users (Headless application that can be run on servers and desktops and controlled from CLI)
End Users (JavaFX GUI)

Source Code

https://github.com/Groestlcoin/eclai

Groestlcoin Eclair Mobile (Android) Mainnet + Testnet

Groestlcoin Eclair Mobile can be used as a regular Groestlcoin wallet and can also connect to the Lightning Network for cheap and instant payments.

Features

Source Code

https://github.com/Groestlcoin/eclair-mobile

Download Link

Main net
Test-Net

C-Lightning

C-Lightning is a specification-compliant Lightning Network implementation built in C. It is a lightweight, highly customisable and standard compliant implementation of the Lightning Network protocol. C-Lightning only works on Linux and Mac OS and requires a local or remote instance of Groestlcoind (version 2.16 or above) that is fully synced to the correct blockchain.

Features

Build Guides

Linux
Mac OS

Source Code

https://github.com/Groestlcoin/lightning

Groestlcoin LND

The Lightning Network Daemon (LND) is a complete implementation of a Lightning Network Node. LND has several pluggable back-end chain services including GRSD (A full-node), groestlcoind, and neutrino (a new experimental light client). The project's codebase uses the GRSSuite set of Groestlcoin libraries and exports a large set of isolated re-usable Lightning Network related libraries within it.

Features

Download

Windows
Mac OS X
Linux

Source Code

https://github.com/Groestlcoin/lnd/

Groestlcoin Lightning Network Explorer – Mainnet & Testnet

Groestlcoin Lightning Network Explorer is a simple lightning network explorer that uses LND or C-Lightning as a source of the network graph. You can now look up how many LN nodes and channels there are on GRS Mainnet or Testnet.

Requirements

Features

View:

Main net
Test net

Source Code

https://github.com/Groestlcoin/recksplorer

Groestlcoin Lightning Wallet (GLW) for Android – Mainnet & Testnet

The Groestlcoin Lightning Wallet features a standalone SPV Groestlcoin wallet with a fully functional built-in Lightning node. It allows users to send and receive regular on-chain transactions as well as off-chain Lightning Payments.

Features

Downloads

Main net
Test-net

Source Code

Groestlcoin Lightning Wallet
Olympus

ZAP GRS Lightning Wallet – Cross-Platform (Windows, Mac OS, Linux, Android )

ZAP GRS is a free cross-platform Lightning-Network wallet focused on the user experience and ease-of-use. The overall goal of this wallet is to help the cryptocurrency community scale Groestlcoin. This wallet grants you the ability to trustlessly send and receive Groestlcoin instantly with minimal fees via the Lightning Network. Manage your private keys, multiple wallets and open channels to get connected with other peers on the Lightning Network and start transacting the future, today.

Features

Downloads

Windows
Mac OS
Linux
Android

Source Code

Android
Desktop

Groestlcoin Spark Lightning Wallet – Cross-Platform (Windows, Mac OS, Linux, Android)

Groestlcoin Spark is a minimalistic wallet GUI for c-lightning through desktop apps. Spark is currently orientated for technically advanced users and is not an all-in-one package, but rather a "remote control" interface for a c-lightning node that must be managed separately. Groestlcoin Spark is a purely off-chain wallet; allowing Groestlcoin to truly realise the power of lightning, that supports sending and receiving payments, viewing history, and managing channels.

Features

Downloads

Windows : Installer - Portable
Mac OS
Linux : Appimage InstallerSnap InstallerDeb Installer
Android

Source Code

Desktop
Android

Zeus GRS

Zeus GRS is a mobile Groestlcoin app for Lightning Network Daemon (LND) node operators.

Requirements

Features

Download

Android: https://play.google.com/store/apps/details?id=org.groestlcoin.zeus

Source Code

https://github.com/Groestlcoin/zeus

GRSD

GRSD is an alternative full-node Groestlcoin implementation written in Go (GOLang). If you want an alternative full-node wallet and are an advanced user, then GRSD is the right choice for you. The wallet will also properly relay newly mined blocks, maintains a transaction pool and relays individual transactions that have not yet made it into a block. It ensures all individual transactions admitted to the pool follow the rules required by the blockchain and also include more strict checks which filter transactions based on miner requirements ("standard" transactions).

Features

Downloads

Windows
OSX
Linux

Source Code

https://github.com/Groestlcoin/grsd/

KWH-GRS Browser Extension (Google Chrome & Mozilla Firefox)

KWH-GRS is a companion browser extension for C-Lightning and Éclair nodes which connects to C-Lightning or Éclair nodes and enables interactions with Lightning apps.

Requirements

Features

Download

Mozilla Firefox
Google Chrome

Source Code

https://github.com/Groestlcoin/kwh

GRS Pay Version 1.0.3.146 – Now Lightning Ready!

GRSPay is a free, open-source, non-custodial cryptocurrency payment processor which allows you to receive payments in Groestlcoin with no fees, transaction cost or middlemen. GRSPay eliminates the involvement of a third-party. Payments with GRSPay go directly to your wallet, which increases privacy and security. Your private keys are never visible to the GRSPay Server or anyone else. There is no address re-use since each invoice generates a new address deriving from your public key.
For more details, click here for the GRSPay launch details and FAQ.

What's New?

View

GRSPay is available at https://grspay.com
GRSPay Testnet is available at https://testnet.grspay.com

Source Code

https://github.com/Groestlcoin/btcpayserver
submitted by Yokomoko_Saleen to groestlcoin [link] [comments]

Syntactic sugar for helper functions

I am creating a functional programming language with syntax similar to Haskell and I am considering adding syntactic sugar for helper functions. For example, a tail recursive implementation of factorial in Haskell might look something like this:
fact = go 1 where go acc 0 = acc go acc n = go (n * acc) (n - 1) 
Having to create a new function with its own name each time you want to do something seems like a perfect place to me to use syntactic sugar. In my language, it might look like this:
fact = case 1 _ of acc 0 -> acc acc n -> rec (n * acc) (n - 1) 
The idea is that an underscore represents a value to be filled in (similar to anonymous functions in Scala) and that the rec keyword is used for tail recursive calls. The case ... of is similar to Haskell except that it takes multiple values to pattern match against to allow for definitions like this.
What do you think about this idea? Do you have a better syntax for it in your language?
Edit: I've decided against the underscore syntax in favor of directly applying the initial accumulator value to the function literal using a pipe operator |> like in Elm:
fact = 1 |> \ acc 0 -> acc acc n -> rec (n * acc) (n - 1) 
This should be less confusing than having a dedicated syntax, although I may also replace the pipe operator with a more clearly-named function.
submitted by scott11x8 to ProgrammingLanguages [link] [comments]

Can't uninstall apps to upgrade firmware

Currently running 1.3.1, I can't uninstall any apps. It says "Unable to remove application". I don't get any prompt on the ledger to allow uninstall
This is what I found in the log files:
2018-05-31T05:16:15.579Z D/Global: (last _firmwares,Some(Success([object Object]))) 2018-05-31T05:16:20.095Z D/Global: apps 2018-05-31T05:16:20.096Z D/Global: 9bb8d31ddf095384b2c991a46e2d3bf9372a4b7b27440b92c55031b319b090b2 2018-05-31T05:16:20.511Z D/Global: Received { 2018-05-31T05:16:20.513Z D/Global: "nonce": 1, 2018-05-31T05:16:20.515Z D/Global: "query": "exchange", 2018-05-31T05:16:20.516Z D/Global: "data": "e00400000431100002" 2018-05-31T05:16:20.518Z D/Global: } 2018-05-31T05:16:20.519Z D/Global: Query: exchange 2018-05-31T05:16:20.530Z V/APDU: => E00400000431100002 2018-05-31T05:16:20.535Z V/APDU: <= 9000 2018-05-31T05:16:51.788Z D/Global: Received { 2018-05-31T05:16:51.790Z D/Global: "query": "error", 2018-05-31T05:16:51.790Z D/Global: "data": "" 2018-05-31T05:16:51.791Z D/Global: } 2018-05-31T05:16:51.792Z D/Global: Query: error 2018-05-31T05:16:51.795Z E/Global: java.lang.Exception:  2018-05-31T05:16:51.796Z E/Global: at $c_jl_Exception.$c_jl_Throwable.fillInStackTrace__jl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/StackTrace.scala:33:4) 2018-05-31T05:16:52.077Z E/Global: at $c_jl_Exception.$c_jl_Throwable.init___T__jl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:12:18) 2018-05-31T05:16:52.078Z E/Global: at java.lang.Exception.(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:269:6) 2018-05-31T05:16:52.079Z E/Global: at {anonymous}()(../../src/main/scala/co/ledgemanageweb/controllers/manageold/OldApplyScriptController.scala:243:15) 2018-05-31T05:16:52.080Z E/Global: at scala.scalajs.runtime.AnonFunction1.apply(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/AnonFunctions.scala:15:37) 2018-05-31T05:16:52.081Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:69:28) 2018-05-31T05:16:52.081Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2018-05-31T05:16:52.082Z E/Global: at WebSocket.(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2018-05-31T05:26:54.768Z D/Global: (last _firmwares,Some(Success([object Object]))) 2018-05-31T05:26:59.998Z D/Global: apps 2018-05-31T05:26:59.998Z D/Global: 641b73915759276f5c529c0801aaacde190c4f963dc39b82aca16b5b96dff4db 2018-05-31T05:27:00.434Z D/Global: Received { 2018-05-31T05:27:00.435Z D/Global: "nonce": 1, 2018-05-31T05:27:00.435Z D/Global: "query": "exchange", 2018-05-31T05:27:00.436Z D/Global: "data": "e00400000431100002" 2018-05-31T05:27:00.437Z D/Global: } 2018-05-31T05:27:00.438Z D/Global: Query: exchange 2018-05-31T05:27:00.441Z V/APDU: => E00400000431100002 2018-05-31T05:27:00.444Z V/APDU: <= 9000 2018-05-31T05:27:00.651Z D/Global: Received { 2018-05-31T05:27:00.652Z D/Global: "query": "error", 2018-05-31T05:27:00.654Z D/Global: "data": "HTTP Error 502: Bad Gateway" 2018-05-31T05:27:00.655Z D/Global: } 2018-05-31T05:27:00.656Z D/Global: Query: error 2018-05-31T05:27:00.660Z E/Global: java.lang.Exception: HTTP Error 502: Bad Gateway 2018-05-31T05:27:00.661Z E/Global: at $c_jl_Exception.$c_jl_Throwable.fillInStackTrace__jl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/StackTrace.scala:33:4) 2018-05-31T05:27:00.663Z E/Global: at $c_jl_Exception.$c_jl_Throwable.init___T__jl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:12:18) 2018-05-31T05:27:00.665Z E/Global: at java.lang.Exception.(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:269:6) 2018-05-31T05:27:00.667Z E/Global: at {anonymous}()(../../src/main/scala/co/ledgemanageweb/controllers/manageold/OldApplyScriptController.scala:243:15) 2018-05-31T05:27:00.669Z E/Global: at scala.scalajs.runtime.AnonFunction1.apply(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/AnonFunctions.scala:15:37) 2018-05-31T05:27:00.670Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:69:28) 2018-05-31T05:27:00.672Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2018-05-31T05:27:00.674Z E/Global: at WebSocket.(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 
I've tried resetting it by entering incorrect pin 3 times and recovering using the 24 word phrase, but all of my installed apps are still there. I've also tried exiting Chrome completely and restarting my computer. No firewalls, no anti-virus, no VPN enabled
submitted by r34p3rex to ledgerwallet [link] [comments]

What is favorite fancy terse expressive elegant language and why?

Hi all!
The title may be weird question, but I think it makes sense if I explain a bit further. Hope this doesn’t become a huge rant! But it will…
I tend to group languages into two groups:
I don’t know if other people use this distinction and if the types have a better name than workhorse and fancy. These are stupid names. How do people call these language types?
And of course, this is just a single way of grouping. You can have compiled and interpreted, and while traditionally more compiled languages are workhorse and more scripting languages are fancy, you can and do have fancy compiled languages and straightforward scripting languages. And of course practicality and elegance are again different variables and you can have many possible combinations.
To better explain, let’s go though some examples. C for example is work-horse like. There is nothing fancy about the C syntax or features, even though it is probably far more complicated than its feature set would imply. But you sit down, tell it what to do in an imperative fashion. Almost the entirety of C can be summed up as calling functions. C++ is the same: it is even more complicated, and if you do not count template-metaprogramming and third party libraries, C++ and its standard library are not fancy. But I’ve seen some third party libraries that really try some fancy expressive things. C# the same, but LINQ is arguably and exception.
In the domain of scripting, Python looks pretty workhorse. It probably the most “C of scripting languages” from the bunch. I have less experience with Perl, but it feels the same.
You can use Ruby in a similar fashion, but Ruby is often described as having a bit of “magic” behind it. I’ve experienced it myself and described it as the “language reading my mind and doing what I want it without telling it to”. Of course, this is a major embellishment, but there is still truth to it. You need to gather a lot of familiarity with the language to program in that style, but I guess this is something that applies to all fancy languages.
So a few questions:
  1. Does my distinction between work-horse and fancy make any sense or is it just in my head.
  2. If it makes sense, what fancy languages do you like to use and why
  3. What fancy languages are there in use today.
Related to the last question, I would like to exclude older more-academic languages that you can’t really get a job in, languages you can list for question #2. I’m not looking for a job, only I’ve noticed that a lot of fancy languages are older and more academic, not really in widespread use in a practical way in 2017. Most of these fancy older languages pioneered some new concept in programming.
And as an answer to the same question, I would say Ruby and Scala.
And Scala, while I think it is very difficult to learn, is really up there on the fancy scale. I don’t think there is any other languages that are in use and modern that even come close. Or maybe I’m wrong…
That concludes the main part of the question. The rest is the PS with the motivation for this question.

PS:

I started thinking about his related to the programming language I’m implementing: it was designed to be implemented in two phase. Phase 1 are the work-horse features, phase 2 the fancy stuff.
It was decided that it is imperative to first set a rock solid feature set that would form a great foundation made out of only wok-horse like features. The idea was to create a language which if some very experienced developer picks up for the first time, he/she could start writing decent code in a couple of days and in couple of weeks could say that decent mastery over the entire language was achieved.
Such a language is very straight forward, imperative and unambiguous. It can also be stuffy and verbose. This is where the super-expressive fancy stuff comes in, phase 2. Initially the design was based on several other languages, but Ruby had a big part in it. Now I’m thinking some of Scala like feature would be a better fit.
So again, what fancy languages do you like and why? I’ll try to understand the reasoning and try to assess the “value” of these features.

PS2:

Implementing a fancy compiler is ridiculously hard. Our compiler is so not up to the task that it is almost funny.
And our compiler does try to be a bit clever by design and it is still not enough, by a wide margin.
Let me give a quick contrived example: let’s say you want to create a fixed length C array with two strings in it, strings obtained from converting objects to string, let’s say two integers.
val c = CArray[1.ToString(), 2.ToString()] 
That is the same as saying:
val c = CArray[“1”, “2”] 
A bit of a context: the [] syntax is an abstract collection of items which when not being forced to become a concrete type, will decay to the most straightforward dynamic vector. So [1, 2] is an abstract collection of the items 1 and 2, and it could be anything, but in practice, if you just go val a = [1, 2], “a” will be a mutable dynamic heap allocated vector of integers. Prefixing the [] syntax with Foo[] will override the decay to the class Foo which must be a container, so List[1, 2] will be a list and CArray will be a classic C array with fixed size and no length stored at runtime. With this decaying mechanism and the type inference, the compiler looks like a good fit for the fancy stuff. Or so I thought…
Fancy often means functional, lambdas, tuples and more algebraic types, patterns and so on. And the compiler is not up for that. Yet! I started updating the specs from a more Ruby inspired design to a more Scala inspired design, and immediately rewrote that sample as:
val c: CArray = [1, 2].Apply(_.ToString()) 
This is really basic stuff, but there is a ton going on. [1, 2] is a vector of integers. You Apply in a functional style an anonymous lambda that goes though the elements and returns a new vector. Our programming language is natively compiled, statically typed and needs to be pretty much one of the fastest thing possible. So you can’t create a temporary [1, 2], apply ToString to each element and return a new vector with the results of the application in it. Which is then overridden to be a CArray by the val c: CArray syntax, so the whole vector was a CArray all the time, only it did not know it when it was created. And you can’t afford to execute the anonymous lambdas as function calls.
Basically, the compiler needs to take:
val c: CArray = [1, 2].Apply(_.ToString()) 
And spit out
val c = CArray[1.ToString(), 2.ToString()] 
Completely transparently to the user, with zero performance overhead. Basically the assembly for the two samples must be identical.
And it needs to make sure to do proper copy elision, so if you do something like this in pseudocde:
%tmp1% = 1.ToString() %tmp2% = 2.ToString() val c = CArray[%tmp1%, %tmp2%] => Alloca c = CArray[2] => copy %tmp1% to c[0] => copy %tmp2% to c[1] => destroy %tmp1% => destroy %tmp2% 
Then you are doing it all wrong!
You need to do:
alloca c = CArray[2] 1.ToString(&c[0]) 2.ToString(&c[1]) 
In short, compiling this is both hell and a total blast!
submitted by MasterZean to ProgrammingLanguages [link] [comments]

Ledger Manager Unable to Install Ripple Wallet

I fire up the chrome app, enter pin, click Ripple icon in list of apps, and get error shown in screenshot below.
Device has most up to date firmware v1.3.1 running.
Any ideas on what's going wrong???
Screenshot of Error Message: https://imgur.com/a/4vUxl
Error Logs: 2017-10-06T21:58:32.913Z D/Global: start discovery 2017-10-06T21:58:32.928Z D/Global: device discovery 2017-10-06T21:58:33.461Z D/Global: need fix called 2017-10-06T21:58:33.465Z V/APDU: => E001000000 2017-10-06T21:58:33.479Z V/APDU: <= 3110000205312E332E31048600000004312E30009000 2017-10-06T21:58:33.488Z D/Global: notneeded 2017-10-06T21:58:33.491Z D/Global: get firmware version 2017-10-06T21:58:33.494Z V/APDU: => E001000000 2017-10-06T21:58:33.508Z V/APDU: <= 3110000205312E332E31048600000004312E30009000 2017-10-06T21:58:33.514Z D/Global: get firmware version 2017-10-06T21:58:33.518Z V/APDU: => E001000000 2017-10-06T21:58:33.532Z V/APDU: <= 3110000205312E332E31048600000004312E30009000 2017-10-06T21:58:33.544Z I/HTTP: [GET] https://api.ledgerwallet.com/update/devices 2017-10-06T21:58:34.198Z I/HTTP: [GET] https://api.ledgerwallet.com/update/devices - 200 success 2017-10-06T21:58:34.256Z D/Global: old controller 2017-10-06T21:58:34.270Z I/HTTP: [GET] https://api.ledgerwallet.com/update/applications 2017-10-06T21:58:34.280Z I/HTTP: [GET] https://api.ledgerwallet.com/update/firmwares 2017-10-06T21:58:34.291Z D/Global: (last firmwares,Some(List(scala.concurrent.impl.CallbackRunnable@13))) 2017-10-06T21:58:35.013Z I/HTTP: [GET] https://api.ledgerwallet.com/update/firmwares - 200 success 2017-10-06T21:58:35.026Z D/Global: (json,{"nanos":[{"notes":"New in this version\n=======\n\nPIN codes are now up to 8 digits \nChange your PIN without resetting the device \nAuto-lock device when inactive \nPlausible deniability with secure passphrase entry \nReset your device from the Settings app \nSupport for personal certificates \n\nFixed bugs\n=======\n\nBetter USB 3.0 compatibility \nSecurity fixes \n\nWarning\n=======\n\nUpdating your firmware will erase your applications and device configuration. Your recovery phrase is required to restore your accounts after the upgrade. Do not proceed without it.\n","identifier":"52acd248c386e4c7e3be087c7389c64de49b23bb98798534823dd05faacd6253","osu":{"hash":"78ef4503452b5810b42e6e715d4fe8ff3765f06758c78eefe3977e1949a12503","firmware":"nanos/1.3.1/upgrade_osu_1.3.1","targetId":823132162,"perso":"perso_11","firmwareKey":"nanos/1.3.1/upgrade_osu_1.3.1_key"},"name":"1.3.1","final":{"hash":"74d10f134677adb030bafce8adb70c6510e7181a9aae509159f904be01edeed2","firmware":"nanos/1.3.1/upgrade_1.3.1","targetId":823132162,"perso":"perso_11","firmwareKey":"nanos/1.3.1/upgrade_1.3.1_key"}}]}) 2017-10-06T21:58:35.031Z D/Global: (firmwares,[object Object]) 2017-10-06T21:58:35.086Z I/HTTP: [GET] https://api.ledgerwallet.com/update/applications - 200 success 2017-10-06T21:58:35.112Z D/Global: Some(true) 2017-10-06T21:58:35.114Z D/Global: Some(true) 2017-10-06T21:58:35.118Z D/Global: Some(true) 2017-10-06T21:58:35.121Z D/Global: Some(true) 2017-10-06T21:58:35.125Z D/Global: Some(true) 2017-10-06T21:58:35.128Z D/Global: Some(true) 2017-10-06T21:58:35.132Z D/Global: Some(true) 2017-10-06T21:58:35.134Z D/Global: Some(true) 2017-10-06T21:58:35.138Z D/Global: Some(true) 2017-10-06T21:58:35.141Z D/Global: Some(true) 2017-10-06T21:58:35.146Z D/Global: Some(true) 2017-10-06T21:58:35.149Z D/Global: Some(true) 2017-10-06T21:58:35.156Z D/Global: Some(true) 2017-10-06T21:58:35.159Z D/Global: Some(true) 2017-10-06T21:58:35.164Z D/Global: Some(true) 2017-10-06T21:58:35.166Z D/Global: Some(true) 2017-10-06T21:58:35.172Z D/Global: Some(true) 2017-10-06T21:58:35.175Z D/Global: Some(true) 2017-10-06T21:58:35.179Z D/Global: Some(true) 2017-10-06T21:58:35.181Z D/Global: Some(true) 2017-10-06T21:58:35.186Z D/Global: Some(true) 2017-10-06T21:58:35.189Z D/Global: Some(true) 2017-10-06T21:58:35.193Z D/Global: Some(true) 2017-10-06T21:58:35.196Z D/Global: Some(true) 2017-10-06T21:58:35.200Z D/Global: Some(true) 2017-10-06T21:58:35.203Z D/Global: Some(true) 2017-10-06T21:58:35.206Z D/Global: Some(true) 2017-10-06T21:58:35.208Z D/Global: Some(true) 2017-10-06T21:58:35.212Z D/Global: Some(true) 2017-10-06T21:58:35.215Z D/Global: Some(true) 2017-10-06T21:58:35.219Z D/Global: Some(true) 2017-10-06T21:58:35.221Z D/Global: Some(true) 2017-10-06T21:58:35.226Z D/Global: Some(true) 2017-10-06T21:58:35.230Z D/Global: Some(true) 2017-10-06T21:58:35.235Z D/Global: Some(false) 2017-10-06T21:58:35.238Z D/Global: Some(true) 2017-10-06T21:58:35.242Z D/Global: Some(false) 2017-10-06T21:58:35.246Z D/Global: Some(true) 2017-10-06T21:58:35.252Z D/Global: Some(false) 2017-10-06T21:58:35.255Z D/Global: Some(true) 2017-10-06T21:58:35.260Z D/Global: Some(false) 2017-10-06T21:58:35.263Z D/Global: Some(true) 2017-10-06T21:58:35.266Z D/Global: Some(false) 2017-10-06T21:58:35.269Z D/Global: Some(true) 2017-10-06T21:58:35.273Z D/Global: Some(false) 2017-10-06T21:58:35.276Z D/Global: Some(true) 2017-10-06T21:58:35.281Z D/Global: Some(false) 2017-10-06T21:58:35.283Z D/Global: Some(true) 2017-10-06T21:58:35.287Z D/Global: Some(false) 2017-10-06T21:58:35.289Z D/Global: Some(true) 2017-10-06T21:58:35.293Z D/Global: Some(false) 2017-10-06T21:58:35.295Z D/Global: Some(true) 2017-10-06T21:58:35.298Z D/Global: Some(false) 2017-10-06T21:58:35.300Z D/Global: Some(true) 2017-10-06T21:58:35.304Z D/Global: Some(false) 2017-10-06T21:58:35.306Z D/Global: Some(true) 2017-10-06T21:58:35.309Z D/Global: Some(false) 2017-10-06T21:58:35.311Z D/Global: Some(true) 2017-10-06T21:58:35.315Z D/Global: Some(false) 2017-10-06T21:58:35.317Z D/Global: Some(true) 2017-10-06T21:58:35.322Z D/Global: Some(false) 2017-10-06T21:58:35.325Z D/Global: Some(true) 2017-10-06T21:58:35.328Z D/Global: Some(false) 2017-10-06T21:58:35.331Z D/Global: Some(true) 2017-10-06T21:58:35.335Z D/Global: Some(false) 2017-10-06T21:58:35.338Z D/Global: Some(true) 2017-10-06T21:58:35.343Z D/Global: Some(false) 2017-10-06T21:58:35.346Z D/Global: Some(true) 2017-10-06T21:58:35.352Z D/Global: Some(false) 2017-10-06T21:58:35.356Z D/Global: Some(true) 2017-10-06T21:58:35.363Z D/Global: Some(false) 2017-10-06T21:58:35.367Z D/Global: Some(true) 2017-10-06T21:58:35.376Z D/Global: Some(false) 2017-10-06T21:58:35.385Z D/Global: None 2017-10-06T21:58:35.392Z D/Global: Some(false) 2017-10-06T21:58:35.398Z D/Global: None 2017-10-06T21:58:35.406Z D/Global: Some(false) 2017-10-06T21:58:35.413Z D/Global: None 2017-10-06T21:58:35.431Z D/Global: Some(false) 2017-10-06T21:58:35.434Z D/Global: Some(true) 2017-10-06T21:58:35.442Z D/Global: Some(false) 2017-10-06T21:58:35.445Z D/Global: None 2017-10-06T21:58:58.629Z D/Global: apps 2017-10-06T21:58:58.631Z D/Global: 2ffe3223e0e65f4fc735042aefd0b3262390285d615afbe8ee76b13cc3f0a721 2017-10-06T21:58:59.255Z D/Global: Received { 2017-10-06T21:58:59.256Z D/Global: "nonce": 1, 2017-10-06T21:58:59.257Z D/Global: "query": "exchange", 2017-10-06T21:58:59.257Z D/Global: "data": "e00400000431100002" 2017-10-06T21:58:59.258Z D/Global: } 2017-10-06T21:58:59.259Z D/Global: Query: exchange 2017-10-06T21:58:59.271Z V/APDU: => E00400000431100002 2017-10-06T21:58:59.280Z V/APDU: <= 6700 2017-10-06T21:58:59.515Z D/Global: Received { 2017-10-06T21:58:59.518Z D/Global: "query": "error", 2017-10-06T21:58:59.519Z D/Global: "data": "Exception : Invalid status 6700" 2017-10-06T21:58:59.521Z D/Global: } 2017-10-06T21:58:59.523Z D/Global: Query: error 2017-10-06T21:58:59.527Z E/Global: java.lang.Exception: Exception : Invalid status 6700 2017-10-06T21:58:59.529Z E/Global: at $c_jl_Exception.$c_jl_Throwable.fillInStackTracejl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/StackTrace.scala:33:4) 2017-10-06T21:59:00.260Z E/Global: at $c_jl_Exception.$c_jl_Throwable.initTjlThrowable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:12:18) 2017-10-06T21:59:00.262Z E/Global: at java.lang.Exception.(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:269:6) 2017-10-06T21:59:00.264Z E/Global: at {anonymous}()(../../src/main/scala/co/ledgemanageweb/controllers/manageold/OldApplyScriptController.scala:243:15) 2017-10-06T21:59:00.265Z E/Global: at scala.scalajs.runtime.AnonFunction1.apply(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/AnonFunctions.scala:15:37) 2017-10-06T21:59:00.267Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:69:28) 2017-10-06T21:59:00.269Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2017-10-06T21:59:00.271Z E/Global: at WebSocket.(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2017-10-06T21:59:03.192Z D/Global: old controller 2017-10-06T21:59:03.195Z D/Global: (last _firmwares,Some(Success([object Object]))) 2017-10-06T21:59:43.907Z D/Global: apps 2017-10-06T21:59:43.913Z D/Global: 2ffe3223e0e65f4fc735042aefd0b3262390285d615afbe8ee76b13cc3f0a721 2017-10-06T21:59:44.451Z D/Global: Received { 2017-10-06T21:59:44.452Z D/Global: "nonce": 1, 2017-10-06T21:59:44.453Z D/Global: "query": "exchange", 2017-10-06T21:59:44.454Z D/Global: "data": "e00400000431100002" 2017-10-06T21:59:44.455Z D/Global: } 2017-10-06T21:59:44.456Z D/Global: Query: exchange 2017-10-06T21:59:44.460Z V/APDU: => E00400000431100002 2017-10-06T21:59:44.464Z V/APDU: <= 6700 2017-10-06T21:59:44.691Z D/Global: Received { 2017-10-06T21:59:44.693Z D/Global: "query": "error", 2017-10-06T21:59:44.694Z D/Global: "data": "Exception : Invalid status 6700" 2017-10-06T21:59:44.696Z D/Global: } 2017-10-06T21:59:44.697Z D/Global: Query: error 2017-10-06T21:59:44.700Z E/Global: java.lang.Exception: Exception : Invalid status 6700 2017-10-06T21:59:44.702Z E/Global: at $c_jl_Exception.$c_jl_Throwable.fillInStackTracejl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/StackTrace.scala:33:4) 2017-10-06T21:59:44.706Z E/Global: at $c_jl_Exception.$c_jl_Throwable.initTjl_Throwable(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:12:18) 2017-10-06T21:59:44.712Z E/Global: at java.lang.Exception.(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/javalanglib/src/main/scala/java/lang/Throwables.scala:269:6) 2017-10-06T21:59:44.715Z E/Global: at {anonymous}()(../../src/main/scala/co/ledgemanageweb/controllers/manageold/OldApplyScriptController.scala:243:15) 2017-10-06T21:59:44.717Z E/Global: at scala.scalajs.runtime.AnonFunction1.apply(https://raw.githubusercontent.com/scala-js/scala-js/v0.6.9/library/src/main/scala/scala/scalajs/runtime/AnonFunctions.scala:15:37) 2017-10-06T21:59:44.719Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:69:28) 2017-10-06T21:59:44.722Z E/Global: at co.ledger.manager.web.core.net.JsWebSocketFactory$JsWebSocket$$anonfun$1.apply(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46) 2017-10-06T21:59:44.725Z E/Global: at WebSocket.(../../src/main/scala/co/ledgemanageweb/core/net/JsWebSocketFactory.scala:67:46)
submitted by tjc4 to ledgerwallet [link] [comments]

Help with pure functional programming

I'm following the example found in the slides of Pascal Voitot's "20,000 Leagues Under the Sea" Scala IO talk. Specifically to this spec: link
Using the examples of Log and Http, I created my own examples. They are a little long so I'll include the gists for Users.scala and package.scala
I thought I should code for errors as well as success but I feel that my DSL is a little too verbose. Especially when I try to use them in a sample function, addUser. While I would normally use the DB to enforce login name uniqueness, I wanted to see what the code would work itself out to be if I first queried.
However, since QueryForLogin and AddUser return a different disjunction than the addUser function, I need to transform them into Error and Success messages. It seems odd to include these in my DSL as I would need to define more ErroSuccess for different return types (ie: AllUsers).
What would be the best way of defining this simple CRUD DSL? Should I just remove the error return types? If so how would you then code for possible errors?
submitted by vipercmd to scala [link] [comments]

Topics for Week 1

Hi everyone,
After going through a lot of reading materials I have collected, I have narrowed the topics that we can learn for the first week. For the people who are already halfway into learning scala, these may be redundant but you can help us by sharing things that we might have missed.
Following the topics
Day 1 - Introduction(I hate it too, but has to be done)
Day 2 - Variables, Functions & Literals
Day 3 - List, Tuple & Array
Day 4 - Control Structures
Day 5 - Pattern Matching
Day 6 - Class & Object
Day 7 - Case Class
If you think, I have not covered any topic, please let me know in the comments I'll add them here or will add them in the following weeks.
Suggestions are most welcome.
submitted by juror-number-8 to scalastudygroup [link] [comments]

A new scalac phase for sbt support ... the beginning of "a more perfect union"?

Looking at what's cooking (ie, branches that don't show up in the "commit velocity" stats)
@@ -700,6 +706,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) superAccessors -> "add super accessors in traits and nested classes", extensionMethods -> "add extension methods for inline classes", pickler -> "serialize symbol tables", + API -> "summarize symbol tables as API for sbt", refChecks -> "reference/override checking, translate nested objects", uncurry -> "uncurry, translate function values to anonymous classes", tailCalls -> "replace tail calls by jumps", 
Details at: https://github.com/scala/scala/compare/2.12.x...adriaanm:sbt-api-consolidate
As always, lowering the learning curve of sbt is a noble goal! Thanks for that!
submitted by InteractiveWeather to scala [link] [comments]

Week 1 Day 2: Variables, Functions & Literals

var vs val
Scala Variables (tutorial)
What is the difference between a var and val definition in Scala? (Stackoverflow)
Function definition
Scala Functions
Learning Scala – Methods (Blog)
Named parameters
Named Parameters (Scala docs)
Scala functions - named arguments and default arguments (Blog)
Anonymous functions
Anonymous Function Syntax Anonymous Functions (tutorial)
Literals
Scala Data Types (tutorial)
submitted by juror-number-8 to scalastudygroup [link] [comments]

Is it possible to implement Scala PartialFunction in Kotlin?

Hi,
I'm working on a little side project and need a 1:1 implementation of PartialFunction in Kotlin.
I'm at this stage and get 2 errors from IntelliJ ...
... and I don't know how to fix them.
I need in A/out B because another type which uses PartialFunction also specifies its usage of B as out.
EDIT: Do I need A1 and B1 at all or is in/out doing what A1 <: A and B1 >: B is doing in Scala?
EDIT2: This seems to do what I wan't; anyone with enough Scala and Kotlin knowledge able say if it will do what the Scala code does?
submitted by vreid to Kotlin [link] [comments]

I'm working on creating a demographics crowdsourcing system. Some rough edges, but would love feedback.

I've posted about this before, but since then, I've added a bunch of functionality.
I'm working on a creating a platform called Statly ( http://www.statly.net ). It's meant to allow people to combine data from their various accounts online along with social polling to create a demographics dataset. The more services you connect the more questions you answer, the more dimensions are available in the download.
Privacy
Current Services
Question Types
Coming Soon
How long have we been at this?
About 3 or 4 months.
What motivated me to start this?
I'm always looking for interesting demographics datasets, but I can never find them. I think that's silly since if we were to all combine our data, we'd have awesome stuff to mine.
I also took inspiration from this dataset that I found about demographics by zip code on the NYC open data site. I basically wanted this exact data, but larger, and with any dimensions I wanted.
What's your 6-month plan?
Now that I've got at least an minimal viable product done to show it off, we'll likely look to get marketing and SEO start to get focused on. We'll also be going rampant adding connectors to additional services.
What's your sign?
Virgo
Seriously? Facebook's the only way you can login?
For now yes. We'll allow email address sign ups soon enough, but since we also wanted social media connectivity, we went in one direction at first, with the intention of giving people other ways to create an account in the future.
Data Download is only in a big .txt?
That's the next bit of functionality we're working on. You'll be able to to select what columns are included, in what order, which columns will allow nulls, and how the columns are sorted. You'll be able to choose JSON and XML as well as TXT.
Wait...I can't make my own questions? That's dumb.
We're getting there. The creation of questions is definitely something users will be able to do in the future, but at this stage, it's not our top priority quite yet. However, happy to hear feedback on that topic to change my mind.
What's this written in?
The back end is Scala and Elastic Search. The front end is all Twitter Bootstrap with FontAwesome and AngularJS. The visualizations are NVD3.
Help me test this out!
www.statly.net
submitted by timalexander to Entrepreneur [link] [comments]

German Orientalism

Suzanne L. Marchand, German Orientalism in the Age of Empire: Religion, Race and Scholarship,
Current scholars of art historiography are fortunate to have German Orientalism in the Age of Empire. Thirty years ago when I was at work on my dissertation on the Austrian art historian and theorist Alois Riegl, I was disappointed that Orientalism, Edward Said’s important book, purposely ignored exactly those scholars, Germans and Austrians, whose work I encountered as I traveled through nineteenth century academia. I hungered for the kind of guidebook that could help me think myself into their time, place them in a context, and impart something of their backgrounds and interests. Marchand deserves our gratitude for her explorations of countless official and personal archives, and for conveying her subject with the expansiveness of an author who has read widely and the intimacy of one who has read deeply. Said’s Orientalism lurks in the background of German Orientalism, and many of Marchand’s generalizations imply challenges to his assumptions. Yet Marchand rarely addresses his work directly. Instead of merely filling an important gap in his picture of Orientalism, she uses the example of German scholarship to complicate his ideological interpretation of Orientalism. By focusing on the interplay between intellectual, institutional and political history, she reveals the contradictions and opposing forces that informed orientalism and oriental scholarship. Furthermore, Marchand covers different territory from Said. The Orientalism she traces is not focused on the Middle East. Like the nineteenth century scholars she studies, she uses the term “Oriental” to cover East and South Asia as well. She presents a more multifaceted picture of Orientalism by extending it to its pre-Saidian borders, and thus complicates the field mainly for better, but occasionally, as we shall see, for worse. In ten chapters and an epilog, Marchand moves from the Enlightenment, when study of the “Orient” first became possible and even respectable, through the difficult middle decades of the nineteenth century in which “lonely orientalists,” struggled in anonymity and without proper academic positions, to a time, late in the century, when “furious orientalists” fought their way through the combination of sheer antagonism and sometimes audacious theories that challenged received wisdom about the indebtedness of Christianity to Judaism and other subjects. Along the way, she relates how academic positions are won and lost, as the rise and fall of empires nurtured some forms of Orientalist scholarship and discouraged others. She addresses key questions about Western cultural dependence on the East, the origins of Christianity, the status of sacred texts, the organization of disciplines, the establishment of chairs in Orientalistik, the beginning of Religionsgeschichte, the relation of Christianity to Buddhism and Zoroastrianism and many others. She examines the biographies of scholars from Johann Gottfried Herder and Friedrich Creuzer to Ignaz Goldziher and Josef Strzygowski in order to illuminate and problematize the relation between Orientalism and racism. The detailed, complex narrative repeatedly belies easy assumptions about the relationship of knowledge to power. Attempts to use Orientalism to support received religious ideas backfired, and imperial power, too, often failed to determine what scholars would find. Scholars, mere humans wrestling with language, often succumbed to the power of their own ideas. One of the unintended consequences of scholarship is that one can undermine the idea one tries to serve. In her many case studies, Marchand shows how those who tried to use Oriental studies to prove the truth of the scriptures found their own ideas changing instead. Although starting from a detached academic point of view, they often ended up seeing through the eyes of those they studied. Earlier scholars laid the foundation for the work of later scholars who would accuse them of Orientalism. In penetrating discussions of Herder and Johann Salomo Semler, she shows how their attempt to find truth in the “primitive” in fact historicized these cultures and their scriptures: “once [the scriptures are] put in historical and anthropological context, it was difficult to extract them”. Even if the scholars themselves were not changed by their studies, their texts were often used against their intentions, as probably happened, for example, to Johann David Michaelis. Her treatment of Richard Wilhelm and Erwin Baelz challenge received notions about the relation of Orientalists’ prejudices to the colonial function of scholarship. Even when scholars wished to be “relevant” to empire, imperialists were right to worry about their penchant to go native. But for much of the period covered in the book, there was no empire to call the scholarly shots by ensuring or preventing scholarly advancement. How could “lonely orientalists,” working in obscure fields against odds and with no prospect of employment, contribute to ideologies of power? In Chapter Nine, “Interpreting Oriental Art,” art historiography takes center stage. Some of the material is familiar terrain for readers of Marchand’s earlier Down from Olympus or her essay on Josef Strzygowski. Here her vista extends to issues of classification that determine whether a work is to be treated as art or artifact, and to such topics as oriental carpets and exhibitions. Her earlier interest in archaeology expands to include the fascinating and understudied Turfan expeditions to Central Asia. For an art historiographer, the book is especially useful insofar as it looks at art history in the context and from the vantage point of a wider scholarly world out of which it comes: philology, biblical scholarship, orientalist studies. It is useful to watch art historians embarking on the same trips as Oriental philologists and relying on the same conquests, particularly when their object was to build collections. It is instructive to consider comparisons between scholars of Oriental languages and art: whether a catalogue is equivalent to a dictionary, for example. Embedded as it is in a narrative centered on the study of “Oriental” religions and literatures, the visual element that differentiates the study of art history from these other areas does not come through powerfully or distinctly. I therefore hope that this book will inspire others to further work on scholars of visual arts and orientalism. If so, one area of interest is the way in which their work brought them into dialogue with other visual disciplines such as the physical anthropologists, scientists who relied on visual classifications and created portfolios of their drawings and photographs, as did architects, designers and art historians. In their work, culture and racial theory often intersected, thus clarifying the visual dimension of the relations between race and scholarly Orientalism. Scholarly arguments also clarified this relationship. While Strzygowski, as Marchand argues, indeed granted Jews a role in Western art, this was a malevolent role in the wider war of the races to which he ascribed the historical trajectory of western art. The people from the east whom Strzygowski wished to rehabilitate were Aryans. To this end, he attributed the Mshatta façade not to Islamic art, but to the “northern” spirit. When Strzygowski mentioned “Aryans” specifically, he generally meant Persians, a fact that got him in trouble not only with other Orientalists, but eventually with National Socialists as well. The Persians were important to him as the racial “origin” of the Aryans. Marchand’s searching discussion of pan-Babylonism and especially the Bibel-Babel controversy, which shows the stake that some Orientalists had in the significance of origins, here applies to art history. Art historians who thought that the discovery of the origin of a visual form was its key explanatory factor, often equated folk styles of various countries with early styles. Others, however, were wary of this move, and not merely because of a proto-Fabian realization of the equation of Otherness with distance in time. They valued origins lightly because they valued function more. In Altorientalische Teppiche, for example, Riegl attributed ornamental change to culture. There are the usual run of inevitable mistakes: Josef Strzygowski was not Alois Riegl’s student, but his contemporary and rival ). Riegl was a scholar and a curator, not a “connoisseur”; he did not curate a large exhibition of carpets in the Handelsmuseum (curated by Artur von Scala), but only wrote a catalog essay for it. Some information Marchand did not encounter would strengthen, add complexity to (and lengthen) her argument. She is mistaken when she writes that Riegl did not visit the “Orient.” His early work had been informed primarily by pattern books and other illustrations, but he soon changed his mind and traveled to Egypt, visiting Cairo and floating down the Nile to Luxor. He saw the ornaments of Ibn Talun and became convinced that only first hand views of the monuments would suffice for proper scholarly study. In 1901, he wrote impassionedly to his colleague Franz Wickhoff begging him, in connection with a planned publication on Qusayr Amra, to undertake an exhibition to Jordon to see the monument. Riegl tried to underplay the arduous journey, but Wickhoff must have been able to read the subtext and withdrew from the project in favor of Riegl, although in the end Riegl’s health prevented him from going. Marchand could use this anecdote to illustrate her point that accidents of circumstances are often catalysts for Oriental scholarship. It could also suggest the growing significance of the culture of observation whose history and theoretical consequences have been explored by Lorraine Daston and Peter Galison. This concern was vital to art history, and explains the significance for art historians of travel to monuments, although not always the collection of artifacts. Art historians most frequently brought back from these trips not artifacts, but rather photographs. In any case, when he did go to Egypt, Riegl did not divest himself of his prejudices. He was unfortunately not as careful to avoid racial stereotyping as Marchand gives him credit for, and was perfectly capable of Orientalist remarks like the following from his lecture notes: “Even today every Oriental is an egoist. The Oriental essence is ineradicable.” Finally, the inclusion of Jewish studies in a study of Orientalist scholars brings up other issues when the visual arts are at stake. The myth of aniconism encompasses Islamic and Hebrew art and separates both from East Asian art. A further distinction between Jewish art and the other arts grouped among the “oriental” arts was enunciated perhaps best by Heinrich Frauberger (1845-1920), who wrote, concerning the Düsseldorf Museum of Applied Arts, that the collection was “rich in models for the Mohammedan and Buddhist cults, although neither Mohammedans nor Buddhists lived along the Rhein.” The German scholars of Jewish art, unlike German scholars of Buddhism, Islam, or Hindu texts, studied groups whose descendants lived along the Rhein, and perhaps even could count themselves among them. Some, such as the polymath scholar David Kaufmann, who included visual art in his portfolio, who studied Arabic as well as Hebrew medieval sources, and mixed genealogy with theory and philosophy, could have served as an illuminating example. Indeed, the example of Jewish art specifically brings up one of the dangers of Marchand’s dependence on individuals and their histories for explanations: one can end up evoking the very stereotypes that a study of Orientalism should avoid. Her generalization that “the realists adopt the Semites; the dreamers the Aryans” recalls the very Orientalist trope of uninspired Semites and idealist Aryans. Dreaming Jews, who certainly existed, did not tend to adopt the Aryans. The example suggests the limits of individual personality as an explanation. Generalizations and systems often blur or prove contradictory when examined with a close-up lens. When one draws back from the detail in Marchand’s book, and looks at it and the field it covers as a whole, does one see this larger field differently? With all its variations, is Orientalism still only a matter of “Othering” or is there something dialogic in a Bakhtinian sense, about the discourse? Surely if scholarship is a series of conversations, there is material enough in this book for many of them. If further, scholarship aims to widen and open the conversation to those beyond scholarly circles, then Marchand’s aim is very different from that of Said’s book, Orientalism. Indeed, his aim, to be relevant without being opportunistic or instrumental to empire, could be considered a modern installment of the discourse of Orientalism. In Said’s critique of Orientalism past, and his concentration on one well-documented distinction, he advances beyond the works Marchand cites that succeed in making cogent critiques of colonialism. Marchand’s work, which begins by assuming Said’s critique, ends by encompassing it. In addressing the ethics of Orientalism, Marchand works with one foot in the past and one in the present. She not only tries to understand why Orientalists followed the disparate paths that they followed, but she also struggles with what they should have done and, by extension, the ethics of present scholars of the Orient. In our present day of multiplying Arabic majors, her discussion has eerie echoes, which I hope will resound clearly throughout the mass of learned historical detail in this book.
submitted by gitacritic to SouthAsianHistory [link] [comments]

what is anonymous function in scala video

Scala Functions Higher Order, Anonymous Functions etc Scala - Higher Order and Anonymous Functions - YouTube What is Anonymous Function? Understand in brief ... Scala Tutorial - Function Literals - YouTube Scala Tutorial 12 - Anonymous Functions + Default Values ... Scala - Closure in Scala with example {தமிழ்} Define Functions in Scala using Anonymous Inner Class ... Scala Tutorial 16 - Function Currying in Scala - YouTube

Anonymous Functions An anonymous function—also referred to as a lambda —is a block of code that’s passed as an argument to a higher-order function. Wikipedia defines an anonymous function as, “a function definition that is not bound to an identifier.” For example, given a list like this: 2) Passing an anonymous function as a function argument. As a second example of a function being passed as a variable to another function in Scala, that first example is modified so instead of passing a named function into the oncePerSecond function, we pass in an anonymous function directly from the main method. Here's that source code: You want to use an anonymous function in Scala — also known as a function literal — so you can pass it into a method that takes a function, or to assign it to a variable. Scala provides a relatively lightweight syntax for defining anonymous functions. Anonymous functions in source code are called function literals and at run time, function literals are instantiated into objects called function values. Anonymous functions in Scala A function with no name is an anonymous function which is also known as function literal. This type of functions is used when the user wants to create an inline function. In this example, this code is an anonymous function: _ * 2 This is a shorthand way of saying, “Multiply an element by 2.” Once you’re comfortable with Scala, this is a common way to write anonymous functions, but if you prefer, you can also write them using longer forms. Scala Anonymous Function by Shekhar Sharma · May 14, 2020 In scala, when a function is written without a name is know as anonymous function, also called function literal – so you can pass it into a method that takes a function as an argument or assign it to a variable. Let’s understand it with an example below. This is quite long winded. It follows the objected oriented approach of defining an anonymous function and instantiating it on the spot. Lambda Functions. In Scala, we can do all of the above like this (this is the exact equivalent of the code above): In Scala, An anonymous function is also known as a function literal. A function which does not contain a name is known as an anonymous function. An anonymous function provides a lightweight function definition. It is useful when we want to create an inline function. The second is for writing an anonymous function that does a match on its sole parameter. Your f2 is doing this, but not in any useful way. An example would be the anonymous function passed to collect , e.g. List(1, -2, 3) collect { case x if x > 0 => -x } .

what is anonymous function in scala top

[index] [9708] [2817] [9640] [7732] [3984] [9766] [2516] [4544] [7653] [9049]

Scala Functions Higher Order, Anonymous Functions etc

Scala is a functional language, in the sense that every function is a value. If functions are values, and values are objects, it follows that functions thems... Find code here - http://www.codebind.com/scala/function-currying-scala/Currying is the technique of transforming a function that takes multiple arguments in... In scala, method may have multiple parameter lists. When a method is called with a fewer number of parameter lists, then this will yield a function taking the missing parameter lists as its ... In this Scala tutorial, I will talk about anonymous functions or a function literal or a lambda expression. When calling a function we indirectly invoke the apply method on the object that represents the function. We can use the anonymous class syntax for defining ... Scala Function Types - Higher Order, Anonymous and Nested Functions, Closures. What is Anonymous Function? Understand in brief - JavaScript Tutorial - Part 31In this tutorial, we will learn what is an anonymous function. it is very impo... Connect with me or follow me athttps://www.linkedin.com/in/durga0gadirajuhttps://www.facebook.com/itversityhttps://github.com/dgadirajuhttps://www.youtube.co...

what is anonymous function in scala

Copyright © 2024 top.playtoprealmoneygames.xyz