metaclass: (Default)
[personal profile] metaclass
Читал про монады, наткнулся на несамочевидную шизу с mapM для списков:

mapM (\x -> [x-1, x+1]) [10,20,30]
[ [9,19,29], [9,19,31], [9,21,29], [9,21,31], [11,19,29], [11,19,31], [11,21,29], [11,21,31] ]

Пришлось лезть в ghci и описание устройства mapM, чтобы не сойти с ума.

Date: 2009-12-13 10:26 pm (UTC)
From: [identity profile] zhacka (from livejournal.com)
тоже не плохо:
Prelude Control.Monad> replicateM 3 [0,1]
[[0,0,0],[0,0,1],[0,1,0],[0,1,1],[1,0,0],[1,0,1],[1,1,0],[1,1,1]]

Profile

metaclass: (Default)
metaclass

April 2017

S M T W T F S
      1
2345678
9101112 131415
16171819202122
23242526272829
30      

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 4th, 2025 04:32 pm
Powered by Dreamwidth Studios