Thursday, February 10, 2011

Mount And Blade How Do I Get A Fort

screen i to screen i+1 or i-1 for all i between 2 and 8. Additionally, it may be possible to navigate between some other pairs of screens (sometimes only in one direction).

(The only way to find out that the user navigated between some screens is by receiving a procedure call from the system. This procedure should then perform the necessary operations to set up music.)
The user starts in screen 3. When the user is in screens 3 to 6, there must be, normally, some background music chosen randomly out of 100 possible samples of background music. Each sample has a fixed duration. When a sample is finished, a new sample must be randomly chosen and its playback started.
When the user is in screens 2 or 7 or 9, there must be no music heard. However, if the user returns to screens where music is allowed, it should be again switched on to the same sample as was previously playing.

When the user is in screen 2, there is a possibility of navigating to screen 1 (the \n 1, there is an independent choice of background music that has effect only for screen 1. When leaving screen 1 to, say, screen 3, the choice made in screen 8 again has effect for screen 3.

If the user navigates from screen 8 to screen 9 (\ff music. If music is switched off, choices made in screens 1 and 8 are still available but will not result in audible music, until music is again enabled in screen 3. At that point, current choices should have their effect, as if music has been enabled all the time.

If the user leaves the program, the same state of the music on/off switch should be restored when the user starts the program again.

Initially, the user is in screen 3 and music is enabled. (Thus, initially the user should hear a randomly chosen sample.)

An evil twist due to the technical implementation of background music on the system:

In order to switch off the music, it is necessary to execute a single command (\c and start playing a certain sample (whether or not music has been playing at that moment), it is necessary to execute two commands with a small delay between them: \

Monday, January 24, 2011

Waxing Then Bath? Good Idea? Three sources and three sostavnyya part programmirovanіya

раммъ съ помощью формальныхъ методовъ. Есть разные "design patterns", но нѣтъ формальнаго способа провѣрить, что программа работаетъ правильно.

Таковы три составныя части программированія.

Saturday, January 15, 2011

How To Diagnose Rosacea chaource @ 2011-01-15T18: 07:00

Когда-то давно я сочинилъ такое.





(Подражание Мандельштаму)


Поздний зарок твердим. Он отразится в нас

Заревом грозовым,
Золотом зорких глаз.

Наш безумный обет -
Клятва звенящих ос,
Эхоnebyvshih years
In the mirror of blue tears.

Ash twilight of the words
imperiously calls me,
rustling prophetic dreams
storing my soul.

2004-10-01

Sunday, January 9, 2011

Pain On My Left Hill,what To Do

Monads are a design pattern in functional programming. Monads became more known due to their use in Haskell; however, there is nothing Haskell-specific in monads. I think that monads are simply a trick in lambda-calculus, a trick that turned out to be a useful abstraction. I would say that this is perhaps useful in any functional language (it is not so clear to me whether the lazy-evaluation policy of Haskell has any significance for monadic programming).

There is a proliferation of \C In the monadic programming, this functor is Called "lift" rather than "map". Let us denote the type "lists of type to" by the notation "M (a)", emphasizing That We Could Easily Be just as talking about trees with nodes of type a, or Any Other structure made out of the type "a" in Some Way.

The type of "lift" is
Then lift: (a-> b) -> (M (a) -> M (b))
functions ie it maps from a-> b to functions M (a) -> M (b). If

we want to implement "lift" for lists, Could we just write an iterative Implementation, going-through the list. In monadic programming, we do Not do this iteration in "lift", pero INSTEAD we define "lift" through two OTHER FUNCTIONS: "bind" and "unit." When we define Them, we will have defined the \t instead \nd dog we define the "monadic composition" of f1 and f2 as

(bind f2). f1: a-> M (c)

However, we can Also consider "bind" That as an operation contains a separate "flattening" step. Then it is Useful to look at the "flattening" operation separately. The "flattening" operation is Called "join" in the parlance monadic:

join: M (M (x)) -> M (x)

and is, in my view, the core idea of the monad. This idea Can Be Formulated as: there is no reason to enclose x Twice in the "M" layer. A nested "M" container is equivalent to a single "M" container. An object of type "M (M (a))" Can Be Reduced, But standard in a nontrivial way, to an object of type "M (a)." Reduction This is what "join" does. Now suppose we

or"Lift (const x)" is Not Necessarily a constant function! So we not could define

unit x = lift (\\ i -> x) --- Wrong! So


the Functionality of "unit" is not a subset of the Functionality of "lift". We always Need to define "unit" separately.

The lifting of functions is defined Not Necessarily Through Merely lifting of values. So "lift" not can be defined only through "unit." If we know how to make a one-element list out of "x" Not yet we do know how to iterate through to Longer list. The iteration algorithm is hidden in the "bind" function. For this reason, "lift" is definable through "unit" and "bind."

We Can not define "bind" or "lift" through "join" and "unit" alone. "Join" flattens lists, "unit" makes a single-element list [x] from "x", BUT Neither "unit" nor "join" can make a multi-element list out of "x".


Notes:


1. In Our example, "M (a)" Was a list of values of type "a". However, the Same Rules Apply to Other algebraic structures. For example, "M (a)" Could be a tree containing values of type "a" in STI nodes. Or "M (a)" Could be a dictionary with values of type "a".

Or, more simply, "M (a)" Could be a pair [a, x] WHERE X is always a number. Let us look at this last example in more detail.

We define the type "M (a)" as a two-element list [a, x] containing a value of type "a" and a number x. The "unit" operation Needs to extend a value of type "a" into a pair [a, x]. Let us define "unit" by
ad denote this function by the symbol "monadic_composition.) Then We Can compute the composition of These functions: We Have

first f1 a = [sqrt (a), 1] Then we compute



(monadic_composition f1 f2) a = (bind f2) [sqrt (a), 1]
= [cos (sqrt (a)), 1 +2]
= [cos (sqrt (a)), 3]. Thus, the "monadic composition" of f1 and f2 will add the counters. The "total cost" is computed Correctly.

We Could use this kind of monad for Representing functions Whose evaluation "costs" Something. Then the counter on the final value will Be The total cost. Merely We Need to define the functions and Their costs. The monadic code with Computations cleanly Separates the counters, the initial values orf the counters, and the computation of functions themselves.

In this example, we can see in what way the \f type \ould be * equal * to the result of lifting "x" once.

join. unit. unit == unit - On Any functions as type "to" In the example

Above, we Could not Have defined "unit" by

unit a = [a, 1] - Wrong! Because

then (join. Unit. Unit) x = [x, 2] while unit x = [x, 1].

b) If We Have An object of type M (M (a)), and we flatten it, Then we get an object of type M (a), if we now lift it with "unit" Should we get again The Same object as before.

unit. join. unit == unit - as functions on type M (a)

c) There Are, However, Also some "monadic law" concerning "lift" / "bind." This law Seems To Be The expression of the fact-Lifted That the composition of functions is equal to thelift of the composition of the functions. (How can this fail to hold? Or maybe I'm Mistaken here somewhere?)

(lift f). (Lift g) = Lift (f. G)

Now, "lift" can Be defined through "bind" and "unit." Then We Can substitute this definition Above Into the formula and get some identity That contains only "bind" and "unit." If "bind" does not Satisfy That identity, Then the "lift" defined Through It Will Be nonsensical.

I can not find a simple way of understanding That identity, or of writing it in a reasonable way.

3. It is important to note That There is no function for extracting the value of type "a" from a value of type "M (a)." Once Lifted Some value is to the monad, There is no way back. Values Lifted Can Be Used as argumentLifted s to functions or to functions of type a-> M (a) through "monadic composition" (ie "bind). The result is always a value of type M (a).

Conclusions:

- Monadic programming is a trick in lambda-calculus That Consists of Replacing the "lift" functor by "monadic composition".

- Monadic programming has nothing to do with input / output or imperative programming. It is just a Different Way of Structuring code independent Into parts.

- In order to define a monad, one Needs to define "unit" and "bind" Alternatively or "unit", "join" and "lift" That Need to Satisfy Certain Laws.

- Once " unit "and" bind "are defined, we can define" join "and" lift "through Them. Once" join "and" lift "are defined, we can