In terms of tools to use, the listener is for interactive evaluation. Since
Factor programs are often short enough to fit on a few lines, you can type
them into the listener and see what they do.

Programming in a concatenative language is very different. You certainly
don't want to think in terms of variables and assignment. Instead, think
about the intermediate results you want, and how to put them onto the
stack. In this case, the relevant result is the sum of the list, but you
also need to keep the original list around. After you have those two, you
divide. Using the math.vectors command v/n (vector divided by scalar), we
get
{ 1 2 3 }  ! the list
dup    ! make a copy of the list
length  ! get the length of the copy
v/n      ! divide the two

Words like dup are only suitable for very simple tasks since they are
confusing when used excessively. Instead, the combinators cleave, spread,
apply and their derivatives like bi, bi*, tri@, etc. should be used. The
listener prints the stack effect of each command at the bottom, so if you
forget which one is which, you can type them in and see. In this case the
program becomes
{ 1 2 3 }  [ ] [ length ] bi  v/n
.

Marshall

On Sat, Feb 18, 2012 at 3:52 AM, Вадим Тукаев <vadim_tuk...@bk.ru> wrote:

> Please help me to begin programming. I can't do even one step. I have no
> experience in concatenative programming. I now read the book by Brodie, but
> I understand it badly. And that little bits of information, that I
> understand, I can not translate in the Factor. Please give me (and other
> newbies) simple manual. How to write first program step by step.
>
> Some questions:
> 1. What is best win-editor for Factor? Oh no, not Emacs! I mean something
> like Programmer's Notepad.
> 2. What is Listener? It can be used as the editor? I open Listener,
> Browser, Errors...
> 3. I need some simple program. For example, calculation of a percentage
> parity of numbers. Input data: 1, 2, 3. Output data must be 0.167, 0.333,
> 0.5. How to create such program? I don't ask, that you have solved this
> problem for me. Show, how it is necessary to argue. My brain slip.
>
> ------------------------------------------------------------------------------
> Virtualization & Cloud Management Using Capacity Planning
> Cloud computing makes use of virtualization - but cloud computing
> also focuses on allowing computing to be delivered as a service.
> http://www.accelacomm.com/jaw/sfnl/114/51521223/
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to