1 people like it.
Like the snippet!
genner thing
test
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
|
module thingy =
let isSumPossible (target :int) (ints : int list)=
let head, tail =
match ints with
| x::xs -> x,xs
| [] -> 0,List.empty
let combos =
tail
|> List.map (fun i -> head,i )
|> List.filter (fun (i,j) -> (i+j) = target)
combos
|> List.length
|> (<>) 0
let testRandom () =
let rand = new System.Random()
let amount = rand.Next(100);
let sum = rand.Next();
let ints = List.init amount (fun i -> rand.Next())
ints
|> isSumPossible sum
|
val isSumPossible : target:int -> ints:int list -> bool
Full name: Script.thingy.isSumPossible
val target : int
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val ints : int list
type 'T list = List<'T>
Full name: Microsoft.FSharp.Collections.list<_>
val head : int
val tail : int list
val x : int
val xs : int list
Multiple items
module List
from Microsoft.FSharp.Collections
--------------------
type List<'T> =
| ( [] )
| ( :: ) of Head: 'T * Tail: 'T list
interface IEnumerable
interface IEnumerable<'T>
member Head : 'T
member IsEmpty : bool
member Item : index:int -> 'T with get
member Length : int
member Tail : 'T list
static member Cons : head:'T * tail:'T list -> 'T list
static member Empty : 'T list
Full name: Microsoft.FSharp.Collections.List<_>
val empty<'T> : 'T list
Full name: Microsoft.FSharp.Collections.List.empty
val combos : (int * int) list
val map : mapping:('T -> 'U) -> list:'T list -> 'U list
Full name: Microsoft.FSharp.Collections.List.map
val i : int
val filter : predicate:('T -> bool) -> list:'T list -> 'T list
Full name: Microsoft.FSharp.Collections.List.filter
val j : int
val length : list:'T list -> int
Full name: Microsoft.FSharp.Collections.List.length
val testRandom : unit -> bool
Full name: Script.thingy.testRandom
val rand : System.Random
namespace System
Multiple items
type Random =
new : unit -> Random + 1 overload
member Next : unit -> int + 2 overloads
member NextBytes : buffer:byte[] -> unit
member NextDouble : unit -> float
Full name: System.Random
--------------------
System.Random() : unit
System.Random(Seed: int) : unit
val amount : int
System.Random.Next() : int
System.Random.Next(maxValue: int) : int
System.Random.Next(minValue: int, maxValue: int) : int
val sum : int
val init : length:int -> initializer:(int -> 'T) -> 'T list
Full name: Microsoft.FSharp.Collections.List.init
More information