CoCalc Shared FilesHASK1 / haskell2.sagewsOpen in CoCalc with one click!
Authors: ℏal Snyder, William A. Stein
Views : 40
Description: Haskell mode in sagews
%auto haskell = jupyter('haskell') %default_mode haskell
print "Hello world!"
"Hello world!"
:t "tutorialspoint.com"
"tutorialspoint.com" :: [Char]
[[x,x*4] | x <- [1..10]]
[[1,4],[2,8],[3,12],[4,16],[5,20],[6,24],[7,28],[8,32],[9,36],[10,40]]
[[x,x*10] | x <- [1..100]]
[[1,10],[2,20],[3,30],[4,40],[5,50],[6,60],[7,70],[8,80],[9,90],[10,100],[11,110],[12,120],[13,130],[14,140],[15,150],[16,160],[17,170],[18,180],[19,190],[20,200],[21,210],[22,220],[23,230],[24,240],[25,250],[26,260],[27,270],[28,280],[29,290],[30,300],[31,310],[32,320],[33,330],[34,340],[35,350],[36,360],[37,370],[38,380],[39,390],[40,400],[41,410],[42,420],[43,430],[44,440],[45,450],[46,460],[47,470],[48,480],[49,490],[50,500],[51,510],[52,520],[53,530],[54,540],[55,550],[56,560],[57,570],[58,580],[59,590],[60,600],[61,610],[62,620],[63,630],[64,640],[65,650],[66,660],[67,670],[68,680],[69,690],[70,700],[71,710],[72,720],[73,730],[74,740],[75,750],[76,760],[77,770],[78,780],[79,790],[80,800],[81,810],[82,820],[83,830],[84,840],[85,850],[86,860],[87,870],[88,880],[89,890],[90,900],[91,910],[92,920],[93,930],[94,940],[95,950],[96,960],[97,970],[98,980],[99,990],[100,1000]]
import Data.List primesTo m = eratos [2..m] where eratos [] = [] eratos (p:xs) = p : eratos (xs \\ map (*p) [1..m])
primesTo 100
[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]