Created
July 27, 2017 10:20
-
-
Save greymd/bb56d453ab6d1d046d007ee195cbd9b2 to your computer and use it in GitHub Desktop.
Filter numbers which has 2 same factors with Egison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env egison | |
(define $main | |
(lambda [$args] | |
(each display | |
(farray-same2 farray)))) | |
(define $farray | |
(filter 1#(eq? (length %1) 3) | |
(map (p-f $) (take 100 nats)))) | |
(define $farray-same2 | |
(match-all-lambda | |
(list (list integer)) | |
[<join $a <cons (& <cons $g <cons ,g <cons _ <nil>>>> $same) _>> same])) | |
; {2 2 2} | |
; {2 2 3} | |
; {2 2 5} | |
; {3 3 3} | |
; {2 2 7} | |
; {2 2 11} | |
; {3 3 5} | |
; {2 2 13} | |
; {3 3 7} | |
; {2 2 17} | |
; {2 2 19} | |
; {2 2 23} | |
; {3 3 11} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment