Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #34852

Re: Simple Forth problem

From "WJ" <w_a_x_man@yahoo.com>
Newsgroups comp.lang.forth
Subject Re: Simple Forth problem
Date 2014-12-09 05:13 +0000
Organization A noiseless patient Spider
Message-ID <m660cv$7uo$1@dont-email.me> (permalink)
References <l19804$g8k$1@dont-email.me>

Show all headers | View raw


WJ wrote:

> Make a list of the elements that are found in both lists
> at the same index.
> 
> OCaml:
> 
> 
> open List;;
> map fst
>   (filter (fun (x,y) -> x=y)
>           (combine [3;5;7;8;12] [2;5;8;10;12]));;
> 
> [5; 12]
> 
> 
> Using the piping operator (|>):
> 
> 
> combine [3;5;7;8;12] [2;5;8;10;12] |>
> filter (fun (x,y) -> x=y) |>
> map fst ;;
> 
> 
> Since every gavino "knows" that Forth amplifies programmer productivity,
> let's see several Forth solutions that are more concise than the
> OCaml ones.

Gauche Scheme:

(use srfi-42)
(list-ec
  (:parallel (: x '(3 5 7 8 12)) (: y '(2 5 8 10 12)))
  (if (= x y))
  x)

 ===>
(5 12)

Back to comp.lang.forth | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Simple Forth problem "WJ" <w_a_x_man@yahoo.com> - 2014-12-09 05:13 +0000
  Re: Simple Forth problem mix <mix@test.net> - 2014-12-13 08:58 +0000
  Re: Simple Forth problem mix <mix@test.net> - 2014-12-13 09:00 +0000

csiph-web