W👑
Size: a a a
RM
SB
MM
F# with linq.open System
type MyTags = List<string>
type MySong = { Title: string; Tags: Option<MyTags> }
let songs : List<MySong> = [
{ Title = "Cantaloupe Island";
Tags = Some ["60s"; "jazz"]};
{ Title = "Let It Be";
Tags = Some ["60s"; "rock"]};
{ Title = "Knockin' on Heaven's Door";
Tags = Some ["70s"; "rock"]};
{ Title = "Emotion";
Tags = Some ["70s"; "pop"]};
{ Title = "The River";
Tags = None};
]
let extractTagss songs =
query {
for song in songs do
where (song.Tags <> None)
select song.Tags
} |> Seq.toList
[<EntryPoint>]
for tags in (songs |> extractTagss) do
tags |> Console.WriteLine
$ dotnet fsi 14-linq.fsx
/home/epsi/Documents/songs/fsharp/14-linq.fsx(27,23): error FS0001: The type 'List<MySong>' is not compatible with the type 'Linq.IQueryable<MySong>'
AH
F# with linq.open System
type MyTags = List<string>
type MySong = { Title: string; Tags: Option<MyTags> }
let songs : List<MySong> = [
{ Title = "Cantaloupe Island";
Tags = Some ["60s"; "jazz"]};
{ Title = "Let It Be";
Tags = Some ["60s"; "rock"]};
{ Title = "Knockin' on Heaven's Door";
Tags = Some ["70s"; "rock"]};
{ Title = "Emotion";
Tags = Some ["70s"; "pop"]};
{ Title = "The River";
Tags = None};
]
let extractTagss songs =
query {
for song in songs do
where (song.Tags <> None)
select song.Tags
} |> Seq.toList
[<EntryPoint>]
for tags in (songs |> extractTagss) do
tags |> Console.WriteLine
$ dotnet fsi 14-linq.fsx
/home/epsi/Documents/songs/fsharp/14-linq.fsx(27,23): error FS0001: The type 'List<MySong>' is not compatible with the type 'Linq.IQueryable<MySong>'
MM
AH
MM
PD
.AsQueryable() (from the System.Linq namespace)MM
.AsQueryable() (from the System.Linq namespace)YT

YT
SN
YT
SN