Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Haskell, 96

f=g.(*2)
g m=unlines$t m(c"/\\"):[t n l|(n,l)<-zip[m,m-1..2]$c['\\':p,p]]
p=c"/ "
c=cycle
t=take

This is not actually competitive against the existing Haskell solutionthe existing Haskell solution because it saves 5 characters by returning instead of printing a string. I am posting it only to show how the infinite pattern approach compares to the coordinate-based approach. Notes:

  • p can be inlined for no change in length.
  • [t n l|(n,l)<-...] saves 2 over (map(uncurry t)$...).

Haskell, 96

f=g.(*2)
g m=unlines$t m(c"/\\"):[t n l|(n,l)<-zip[m,m-1..2]$c['\\':p,p]]
p=c"/ "
c=cycle
t=take

This is not actually competitive against the existing Haskell solution because it saves 5 characters by returning instead of printing a string. I am posting it only to show how the infinite pattern approach compares to the coordinate-based approach. Notes:

  • p can be inlined for no change in length.
  • [t n l|(n,l)<-...] saves 2 over (map(uncurry t)$...).

Haskell, 96

f=g.(*2)
g m=unlines$t m(c"/\\"):[t n l|(n,l)<-zip[m,m-1..2]$c['\\':p,p]]
p=c"/ "
c=cycle
t=take

This is not actually competitive against the existing Haskell solution because it saves 5 characters by returning instead of printing a string. I am posting it only to show how the infinite pattern approach compares to the coordinate-based approach. Notes:

  • p can be inlined for no change in length.
  • [t n l|(n,l)<-...] saves 2 over (map(uncurry t)$...).
Source Link
Kevin Reid
  • 1.7k
  • 10
  • 14

Haskell, 96

f=g.(*2)
g m=unlines$t m(c"/\\"):[t n l|(n,l)<-zip[m,m-1..2]$c['\\':p,p]]
p=c"/ "
c=cycle
t=take

This is not actually competitive against the existing Haskell solution because it saves 5 characters by returning instead of printing a string. I am posting it only to show how the infinite pattern approach compares to the coordinate-based approach. Notes:

  • p can be inlined for no change in length.
  • [t n l|(n,l)<-...] saves 2 over (map(uncurry t)$...).