Category:Egison: Difference between revisions
Content added Content deleted
m (Egison is not on codepad.org) |
No edit summary |
||
Line 8: | Line 8: | ||
{{language programming paradigm|Pattern-matching oriented}} |
{{language programming paradigm|Pattern-matching oriented}} |
||
{{language programming paradigm|functional}} |
{{language programming paradigm|functional}} |
||
'''Egison''' is |
'''Egison''' is the world's first programming language that realized non-linear pattern-matching with backtracking. |
||
We can directly represent pattern-matching against lists, multisets, sets, trees, graphs and any kind of data types. |
|||
Egison makes programming dramatically simple! |
|||
= Pattern Matching Oriented = |
|||
Egison proposes a new paradigm pattern-matching-oriented. The combination of all of the following features enables intuitive powerful pattern-matching. |
|||
* Modularization of the way of pattern-matching |
|||
* Pattern-matching with backtracking |
|||
* Non-linear patterns with lexical scoping |
|||
= Poker Hands Demonstration = |
|||
<lang egison> |
|||
;;; |
|||
;;; |
|||
;;; Poker-hands demonstration |
|||
;;; |
|||
;;; |
|||
;; |
|||
;; Matcher definitions |
|||
;; |
|||
(define $suit |
|||
(algebraic-data-matcher |
|||
{<spade> <heart> <club> <diamond>})) |
|||
(define $card |
|||
(algebraic-data-matcher |
|||
{<card suit (mod 13)>})) |
|||
;; |
|||
;; A function that determins poker-hands |
|||
;; |
|||
(define $poker-hands |
|||
(lambda [$cs] |
|||
(match cs (multiset card) |
|||
{[<cons <card $s $n> |
|||
<cons <card ,s ,(- n 1)> |
|||
<cons <card ,s ,(- n 2)> |
|||
<cons <card ,s ,(- n 3)> |
|||
<cons <card ,s ,(- n 4)> |
|||
<nil>>>>>> |
|||
<Straight-Flush>] |
|||
[<cons <card _ $n> |
|||
<cons <card _ ,n> |
|||
<cons <card _ ,n> |
|||
<cons <card _ ,n> |
|||
<cons _ |
|||
<nil>>>>>> |
|||
<Four-of-Kind>] |
|||
[<cons <card _ $m> |
|||
<cons <card _ ,m> |
|||
<cons <card _ ,m> |
|||
<cons <card _ $n> |
|||
<cons <card _ ,n> |
|||
<nil>>>>>> |
|||
<Full-House>] |
|||
[<cons <card $s _> |
|||
<cons <card ,s _> |
|||
<cons <card ,s _> |
|||
<cons <card ,s _> |
|||
<cons <card ,s _> |
|||
<nil>>>>>> |
|||
<Flush>] |
|||
[<cons <card _ $n> |
|||
<cons <card _ ,(- n 1)> |
|||
<cons <card _ ,(- n 2)> |
|||
<cons <card _ ,(- n 3)> |
|||
<cons <card _ ,(- n 4)> |
|||
<nil>>>>>> |
|||
<Straight>] |
|||
[<cons <card _ $n> |
|||
<cons <card _ ,n> |
|||
<cons <card _ ,n> |
|||
<cons _ |
|||
<cons _ |
|||
<nil>>>>>> |
|||
<Three-of-Kind>] |
|||
[<cons <card _ $m> |
|||
<cons <card _ ,m> |
|||
<cons <card _ $n> |
|||
<cons <card _ ,n> |
|||
<cons _ |
|||
<nil>>>>>> |
|||
<Two-Pair>] |
|||
[<cons <card _ $n> |
|||
<cons <card _ ,n> |
|||
<cons _ |
|||
<cons _ |
|||
<cons _ |
|||
<nil>>>>>> |
|||
<One-Pair>] |
|||
[<cons _ |
|||
<cons _ |
|||
<cons _ |
|||
<cons _ |
|||
<cons _ |
|||
<nil>>>>>> |
|||
<Nothing>]}))) |
|||
;; |
|||
;; Demonstration code |
|||
;; |
|||
(poker-hands {<Card <Club> 12> |
|||
<Card <Club> 10> |
|||
<Card <Club> 13> |
|||
<Card <Club> 1> |
|||
<Card <Club> 11>});=><Straight-Flush> |
|||
(poker-hands {<Card <Diamond> 1> |
|||
<Card <Club> 2> |
|||
<Card <Club> 1> |
|||
<Card <Heart> 1> |
|||
<Card <Diamond> 2>});=><Full-House> |
|||
(poker-hands {<Card <Diamond> 4> |
|||
<Card <Club> 2> |
|||
<Card <Club> 5> |
|||
<Card <Heart> 1> |
|||
<Card <Diamond> 3>});=><Straight> |
|||
(poker-hands {<Card <Diamond> 4> |
|||
<Card <Club> 10> |
|||
<Card <Club> 5> |
|||
<Card <Heart> 1> |
|||
<Card <Diamond> 3>});=><Nothing> |
|||
</lang> |
Revision as of 07:24, 22 April 2014
Egison
This programming language may be used to instruct a computer to perform a task.
Listed below are all of the tasks on Rosetta Code which have been solved using Egison.
This programming language may be used to instruct a computer to perform a task.
Official website |
---|
Garbage collected: | Yes |
---|---|
Type safety: | Safe |
Type strength: | Strong |
Type checking: | Dynamic |
See Also: |
Egison is the world's first programming language that realized non-linear pattern-matching with backtracking. We can directly represent pattern-matching against lists, multisets, sets, trees, graphs and any kind of data types. Egison makes programming dramatically simple!
Pattern Matching Oriented
Egison proposes a new paradigm pattern-matching-oriented. The combination of all of the following features enables intuitive powerful pattern-matching.
- Modularization of the way of pattern-matching
- Pattern-matching with backtracking
- Non-linear patterns with lexical scoping
Poker Hands Demonstration
<lang egison>
- Poker-hands demonstration
- Matcher definitions
(define $suit
(algebraic-data-matcher {<spade> <heart> <club> <diamond>}))
(define $card
(algebraic-data-matcher {<card suit (mod 13)>}))
- A function that determins poker-hands
(define $poker-hands
(lambda [$cs] (match cs (multiset card) {[<cons <card $s $n> <cons <card ,s ,(- n 1)> <cons <card ,s ,(- n 2)> <cons <card ,s ,(- n 3)> <cons <card ,s ,(- n 4)> <nil>>>>>> <Straight-Flush>] [<cons <card _ $n> <cons <card _ ,n> <cons <card _ ,n> <cons <card _ ,n> <cons _ <nil>>>>>> <Four-of-Kind>] [<cons <card _ $m> <cons <card _ ,m> <cons <card _ ,m> <cons <card _ $n> <cons <card _ ,n> <nil>>>>>> <Full-House>] [<cons <card $s _> <cons <card ,s _> <cons <card ,s _> <cons <card ,s _> <cons <card ,s _> <nil>>>>>> <Flush>] [<cons <card _ $n> <cons <card _ ,(- n 1)> <cons <card _ ,(- n 2)> <cons <card _ ,(- n 3)> <cons <card _ ,(- n 4)> <nil>>>>>> <Straight>] [<cons <card _ $n> <cons <card _ ,n> <cons <card _ ,n> <cons _ <cons _ <nil>>>>>> <Three-of-Kind>] [<cons <card _ $m> <cons <card _ ,m> <cons <card _ $n> <cons <card _ ,n> <cons _ <nil>>>>>> <Two-Pair>] [<cons <card _ $n> <cons <card _ ,n> <cons _ <cons _ <cons _ <nil>>>>>> <One-Pair>] [<cons _ <cons _ <cons _ <cons _ <cons _ <nil>>>>>> <Nothing>]})))
- Demonstration code
(poker-hands {<Card <Club> 12>
<Card <Club> 10> <Card <Club> 13> <Card <Club> 1> <Card <Club> 11>});=><Straight-Flush>
(poker-hands {<Card <Diamond> 1>
<Card <Club> 2> <Card <Club> 1> <Card <Heart> 1> <Card <Diamond> 2>});=><Full-House>
(poker-hands {<Card <Diamond> 4>
<Card <Club> 2> <Card <Club> 5> <Card <Heart> 1> <Card <Diamond> 3>});=><Straight>
(poker-hands {<Card <Diamond> 4>
<Card <Club> 10> <Card <Club> 5> <Card <Heart> 1> <Card <Diamond> 3>});=><Nothing>
</lang>
Pages in category "Egison"
The following 8 pages are in this category, out of 8 total.