5 ms·
Print 1 to 10, as a comma-separated list. In e.g. Scala, you can do that: print( 1 to 10 mkString "," ) It's not 100% human language/grammar, but close (and
by wiradikusuma 8y ago
Print 1 to 10, as a comma-separated list.
In e.g. Scala, you can do that:
print( 1 to 10 mkString "," )
It's not 100% human language/grammar, but close (and you have auto-completion using IDE). Why would you need another DSL?
(Not trying to bash Avail, nor promote Scala, just curious for its usecases)
- jhall1468 8y agoI'm pretty sure the goal of these "natural language style" programming languages extends beyond printing a comma-delimited list of numbers. This arbitrary example doesn't mean much.
- p1necone 8y agoIt's not a very good example though - it's not showing me any sort of improvement over actual programming languages - just an intentionally bad bit of code.
- Athas 8y agoI agree; defining well-named functions seem a superior solution. In Haskell, it would just be: print (intercalate ", " [1..10]) I don't buy natural-language-ish programming languages. The grammar becomes far too complicated very quickly. A simple but flexible grammar, a la most functional languages, is superior.
- tomp 8y agoI hope you didn't mean to imply that `intercalate` is a _well-named_ function... I've no idea what it means, and even after a dictionary search it's still not obvious to me why you'd ever name a method like this!
- bausshf 8y agoIt's kind of a bad name, but not entirely. This is the definition of intercalate. --- intercalate [in-tur-kuh-leyt] verb (used with object), in·ter·ca·lat·ed, in·ter·ca·lat·ing. 1. to interpolate; interpose. 2. to insert (an extra day, month, etc.) in the calendar.