Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Monads-Writer-monad/J/monads-writer-monad-1.j
Normal file
27
Task/Monads-Writer-monad/J/monads-writer-monad-1.j
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
root=: %:
|
||||
incr=: >:
|
||||
half=: -:
|
||||
|
||||
tostr=: ,@":
|
||||
|
||||
loggingVersion=: conjunction define
|
||||
n;~u
|
||||
)
|
||||
|
||||
Lroot=: root loggingVersion 'obtained square root'
|
||||
Lincr=: incr loggingVersion 'added 1'
|
||||
Lhalf=: half loggingVersion 'divided by 2'
|
||||
|
||||
loggingUnit=: verb define
|
||||
y;'Initial value: ',tostr y
|
||||
)
|
||||
|
||||
loggingBind=: adverb define
|
||||
r=. u 0{::y
|
||||
v=. 0{:: r
|
||||
v;(1{::y),LF,(1{::r),' -> ',tostr v
|
||||
)
|
||||
|
||||
loggingCompose=: dyad define
|
||||
;(dyad def '<x`:6 loggingBind;y')/x,<loggingUnit y
|
||||
)
|
||||
7
Task/Monads-Writer-monad/J/monads-writer-monad-2.j
Normal file
7
Task/Monads-Writer-monad/J/monads-writer-monad-2.j
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
0{::Lhalf`Lincr`Lroot loggingCompose 5
|
||||
1.61803
|
||||
1{::Lhalf`Lincr`Lroot loggingCompose 5
|
||||
Initial value: 5
|
||||
obtained square root -> 2.23607
|
||||
added 1 -> 3.23607
|
||||
divided by 2 -> 1.61803
|
||||
Loading…
Add table
Add a link
Reference in a new issue