[Factor-talk] Wish list

2013-12-15 Thread graham telfer

Hi,

One thing I really miss in Factor is a constraint programming library. 
Something like Choco for Python that works with MiniZinc or Gecode that is 
implemented in C++.
Sent from my iPad
--
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET,  PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831iu=/4140/ostg.clktrk
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Cookbook and Learning

2013-06-17 Thread graham telfer
The lack of tutorials for Factor is a major bugbear. I have found The Rosetta 
Code site very useful because you can compare Factor code with a language you 
already know for many different problems.

Chapter 4 of Thinking Forth is also useful because it has a lot of good advice 
about factoring code.

--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Cookbook and Learning

2013-06-17 Thread graham telfer
I would initially like to see 2 tutorials: one which teaches the basics of 
Factor in the manner of Learn you a Haskell for Great Good stressing the 
functional programming paradigm. It should get a beginner to the point of being 
able to think about problems in a functional way and compose functions to solve 
those problems in the Factor idiom.

A second tutorial emphasising real world problems with somewhat longer examples 
exemplified by some of John Benediktsson's blog posts would be my choice of a 
follow-up.

After that some more academic books using Factor in a traditional computer 
science course and video lectures to match the many using Python or Haskell is 
a wish list. --
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Constraints on sequence functions

2013-06-04 Thread graham telfer
I am trying to define a word; bagof which will collect subsequences of values 
that satisfy some constraints.

: bagof  ( seq -- set-of-sub-sequences )
constraints-to-satisfy collect-the-sub-sequences ;

Constraints might be anything but for example at the moment I want to collect 
the bag of integers for which the sum = some value. I would like to define the 
summing constraint using something like sum or foldl/r or reduce with map but I 
can't find a way to halt the summing process midway and test the constraint or 
repeat the function to build the outputs set.
   
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Constraints on sequence functions

2013-06-04 Thread graham telfer
Maybe happiness! Perhaps the math.combinatorics vocabulary has what I need.

Sent from my iPad

On 5 Jun 2013, at 12:45, graham telfer gakouse...@hotmail.com wrote:

 I am trying to define a word; bagof which will collect subsequences of values 
 that satisfy some constraints.
 
 : bagof  ( seq -- set-of-sub-sequences )
constraints-to-satisfy collect-the-sub-sequences ;
 
 Constraints might be anything but for example at the moment I want to collect 
 the bag of integers for which the sum = some value. I would like to define 
 the summing constraint using something like sum or foldl/r or reduce with map 
 but I can't find a way to halt the summing process midway and test the 
 constraint or repeat the function to build the outputs set.

--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Test Driven Development

2013-05-26 Thread graham telfer
Hi,

Test driven development completely baffles me.  Any advice on this topic and 
how to make effective use of Factor's tools?


--
Try New Relic Now  We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app,  servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] List Comprehension in Factor

2013-05-20 Thread graham telfer
I was checking out the Rosetta Code site and noticed there is no example of 
list comprehension in Factor. How can we simulate this convenient tool?

--
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] length

2012-08-29 Thread graham telfer

I'm using Windows Vista.

From: gakouse...@hotmail.com
To: factor-talk@lists.sourceforge.net
Subject: length
Date: Wed, 29 Aug 2012 01:38:15 +





Using sequences in Factor 0.95 I type something like { 1 2 3 } length  in the 
Listener but get nothing returned. 
The stack is not empty though because ' .s ' does not report stack underflow. 
It prints out a blank. Typing ' . . '  prints a blank line rather than the 
length of the sequence and then the stack underflow message as expected.

  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Literate Programming

2012-08-29 Thread graham telfer

I just pushed a vocab with some ideas that might help you get started:

USE: literate

LITERATE

This is a section that is mostly text... you can even include factor stuff
that doesn't get parsed like the following:

: does-this-work? ( -- x ) no it doesn't! ;

But, then if you want to run some code, you can do this:

 : this-totally-works! ( -- x ) 12345 ;

And then some more text, for fun...

LITERATE

Try it and you'll see that the first definition is ignored, but the second
is parsed:

IN: scratchpad \ does-this-work? see
No word named “does-this-work?” found in current vocabulary search path

IN: scratchpad \ this-totally-works! see
: this-totally-works! ( -- x ) 12345 ;

Is something like this what you're looking for?



On Wed, Aug 29, 2012 at 11:07 AM, P. uploa...@gmail.com wrote:

 And just to add that thanks to the ability to manipulate the lexer in
 Factor, you can write a literate programming syntax library and it could be
 however you want it, including exactly like Haskell's.

 - rien

This is pretty much what I was thinking of. I will check out the vocabulary. 

On the matter of approaching the design of software I like to write my thoughts 
as I develop a project. It is not about just commenting code but seeing how 
that code developed out of a thought process.
Perhaps I got into that way of working because I worked as a technical author 
for many years.


From: gakouse...@hotmail.com
To: factor-talk@lists.sourceforge.net
Subject: Literate Programming
Date: Tue, 28 Aug 2012 23:41:06 +





Does Factor have any tools to develop programs using a literate 
programming method? Something like Bird notation used with Haskell or a 
document generator like DocGen with VFXForth. 

The usual thing in code is to mark the comments and leave the code, but in a 
literate programming approach (where there is going to be more comment than 
code) marking the code explicitly would be better.

  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Literate Programming

2012-08-28 Thread graham telfer

Does Factor have any tools to develop programs using a literate 
programming method? Something like Bird notation used with Haskell or a 
document generator like DocGen with VFXForth. 

The usual thing in code is to mark the comments and leave the code, but in a 
literate programming approach (where there is going to be more comment than 
code) marking the code explicitly would be better.
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] length

2012-08-28 Thread graham telfer

Using sequences in Factor 0.95 I type something like { 1 2 3 } length  in the 
Listener but get nothing returned. 
The stack is not empty though because ' .s ' does not report stack underflow. 
It prints out a blank. Typing ' . . '  prints a blank line rather than the 
length of the sequence and then the stack underflow message as expected.
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Time for some Tutorials

2012-08-20 Thread graham telfer

I down loaded and installed the latest version of Factor. The list of 
improvements and new libraries is impressive but pretty scary to a casual user 
of Factor like myself. Isn't it time there were some tutorials available?

I would like to see 3 initially: a beginner's tutorial in the manner of 
Starting Forth, a tutorial that looks more to specification and design of 
programs in a functional style with Factor and a version of Real World Haskell 
for Factor.
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Depth

2012-07-07 Thread graham telfer



Thanks to everybody who gave me suggestions about the stack. I'd like to add a 
final comment about why I think the stack is useful in this case.

Imagine you are going to chop up a carrot to cook it. There are 2 ways you 
might go about the job: the first is to cut off a piece and then turn and put 
it into the pan ready to cook. Keep doing this, cutting one piece at a time, 
turning and putting each piece of carrot into the pan until there is no carrot 
left. The second way is to cut the carrot into pieces and then put all of the 
pieces into the pan as a single operation.

I see the second way as analagous to using the stack. Do all the dividing then 
put all the values into the data structure as a single operation. I do not see 
this as using the stack as a data structure; just a convenient holding pen.
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Stack Depth

2012-06-19 Thread graham telfer

The word narray constructs a sequence but needs an integer to tell it how many 
elements to push. If you want to push all the stack elements how do you find 
the stack's depth? 
  --
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Depth

2012-06-19 Thread Graham Telfer
Doug Coleman doug.coleman@... writes:

 
 In general, you shouldn't want to do this, as all Factor words
 (besides the one I'm about to show you) need a fixed number of
 parameters at compile-time. Macros expand at compile-time, so that's
 one way to get around the restriction.
 
 The other way it to use a slow word called with-datastack:
 
 { 1 2 } [ + ] with-datastack
 
 You can also use smart combinators:
 
 [ 2 1 - 3 ] sum-outputs
 
 This works because the quotation infers at compile-time, and
 sum-outputs is a smart combinator that expands based on the number
 of outputs inferred.
 
 You are trying to do a C varargs function, basically, and just as in
 C, most Factor words are not varags.
 
 If you have more details about what you want to program, we could help you!
 
 Doug

Hi Doug,

I want to divide an integer by 2 until it gets to 1.

I have this snippet of code that goes into a loop.

dup 1  [ dup 2 /i ] [  ] if

When it gets to 1 I want to push the elements into a sequence.


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Depth

2012-06-19 Thread Graham Telfer
Marshall Lochbaum mwlochbaum@... writes:

 
 
 I figured there would be a word designed for that already... Here's my take on
this anyway.
 I would append the items to a sequence as the algorithm goes along:
 { } swap [ dup 1  ] [ dup 2 /i [ suffix ] dip ] while suffixaccomplishes the
task.
 
 Marshall

Hi Marshall,

Yes, this works but I feel the two tasks are conceptually different and I didn't
want to interleave them. I wanted to do all the division as 1 job and then just
push the results as the 2nd job. This way the code stays simple and properly
factored.

Graham



--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Depth

2012-06-19 Thread Graham Telfer
John Benediktsson mrjbq7@... writes:

 
 
 I want to divide an integer by 2 until it gets to 1.
 I have this snippet of code that goes into a loop.
 dup 1  [ dup 2 /i ] [  ] if
 When it gets to 1 I want to push the elements into a sequence.
 
 
 Take a look at the produce word:
 
 : divide-until-2 ( n -- seq )
     [ dup 1  ] [ 2 /i dup ] produce nip ;


Hi John,

produce is exactly what I was looking for. This needs to go into the cook-book
as a useful 1 liner.

Graham


--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


Re: [Factor-talk] Stack Depth

2012-06-19 Thread Graham Telfer
Doug Coleman doug.coleman@... writes:

 
 How would you do this in C? Would you take the return address off the
 stack frame, then start calculating the division-by-2s and pushing
 them to the local stack frame in a loop, and then walk back up
 accumulating them in an array until you hit the return address, at
 which point you return the array?
 
 That's kind of what it sounds like you're suggesting, which would be
 kind of fun but totally impractical. In C, you'd collect them
 immediately after you calculate them, too, just like you should in
 Factor.
 
 The data stack is not for storing all your data, just for threading
 arguments and return values between word calls in a predictable way
 (known stack height.)
 
 Is that helpful? :)
 
 Doug

I know nothing about C. In Prolog an accumulator is exactly what I'd use.

Forth has a Depth word which is partly why I expected one in Factor. When the
job has finished the stack depth is known and 

As an alternative data structure to I tried constructing a list and adding each
new result to it; but the list data structure in Factor is so messy and unwieldy
I quickly decided not to use it. The Lisp words cons cadr are dreadful.
Prolog and Haskell are much more elegant in their use of lists.




--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] Use of While Loop

2011-09-15 Thread graham telfer

Hi,

I am trying to get to grips with Factor. My first attempt is to write a program 
to the following spec:

Pick some positive integer and call it n.
If n is odd, multiply it by three and add one.
If n is even, divide it by two.
Continue this process until n is equal to one.

This is a program in Forth:

: Wondrous ( n -- )
  Begin NotEnd? While
  NumberType? RuleApply Output
  Repeat Drop Cr ;

: NotEnd? ( n -- n,f ) Dup 1  ;
: NumberType? ( n -- n, f ) Dup 2 Mod 0 = ;
: RuleApply ( n -- n ) If EvenRule Else OddRule Then ;
: EvenRule ( n -- n ) 2/ ;
: OddRule ( n -- n ) 3 * 1+ ;
: OutPut ( n -- n ) Dup . ;

There's no tally here which I could add.

So far I have not been able to reproduce this in Factor. I can not work out the 
correct syntax for the While loop.

Can anyone give an example or 2 using simple loops in Factor.




  --
BlackBerryreg; DevCon Americas, Oct. 18-20, San Francisco, CA
http://p.sf.net/sfu/rim-devcon-copy2___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk


[Factor-talk] New to Factor

2011-09-13 Thread graham telfer

Hi there,

I have just downloaded Factor and look forward to learning it. I used to 
program using Forth and it is good to see that one of the major gripes I always 
had about Forth: its lack of data structures and the intoned mantra , Forth 
doesn't provide data structures because it is so easy to design and build your 
own has finally been sunk.

I have a question to ask. One of my interests is constraint programming. Has 
any work been done in Factor towards developing constraint solvers? 
  --
Using storage to extend the benefits of virtualization and iSCSI
Virtualization increases hardware utilization and delivers a new level of
agility. Learn what those decisions are and how to modernize your storage 
and backup environments for virtualization.
http://www.accelacomm.com/jaw/sfnl/114/51434361/___
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk