惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - 未未

用vsstudio 设计Winform 高分屏上布局错乱的问题 jsonToxml 通过LL型方法实现(C#)[源] 数据类型和Json格式[zt] 繁星代码生成器开源 (源代码) 繁星查询分析器 代码生成器 架构提取工具-tqdemo SyCODE Syntax Highlighter javascript语法高亮引擎 自动代码生成和VBA脚本 代码生成工具的分类及比较 模板语法规则说明 繁星代码生成器0.91版 【视频】 0.9版-繁星代码生成器 转:C#开源资源大汇总 代码生成原则Top10 我的系分之路 你必须知道的10种国产编程语言 揭秘正则表达式 我的lxfRegex现实[源] 有关调试的方法 [源码]C# to SQL 的翻译器.net 1.1版
探寻路径
未未 · 2013-02-25 · via 博客园 - 未未
// Learn more about F# at http://fsharp.net
// See the 'F# Tutorial' project for more help.
module File1
open System.Windows.Forms
open System.Collections.Generic

type Loc =
    |A|B|C|D

let path_key a b = if a<b then (a,b) else (b,a)
let path_key_ls (ls:Loc list) = (ls.Head,A)

let pathData =[A,B,4;A,C,1;B,C,1;B,D,1;C,D,4]
let path_Dis_map =  pathData
                    |>List.map (fun (a,b,c)->((path_key a b)),c)
                    |>Map.ofList
path_Dis_map |> Map.toList |>printfn "%A" 

//let dict = new Dictionary<string, string>()
let path_Dis_map2 = new Dictionary< Loc*Loc , int>()

//Map.tryFind
                     
let path_map_query ls map1=
    match ls with
    |head::val1::tail->
        if ( Map.containsKey (A,head) map1) then
            map1.[(A,head)]
        else
            System.Int32.MaxValue
    |_->System.Int32.MaxValue

let rec path_cdis ls=
    match ls with
    |head::a::tail->
        let dis1 = path_Dis_map.[path_key head a]
        dis1 + path_cdis(a::tail)
    |_->0


printfn "dis = %d %d" (path_cdis [D;C;B;A]) (path_map_query [D;C;B;A] path_Dis_map)

let fileterme crr value=

        match value with
        | (a,b,c) when a=crr -> Some(b)
        | (a,b,c) when b=crr ->Some(a)
        | _ ->None
let findway (ls:Loc list) =
    List.choose (fileterme ls.Head) pathData
    |> List.filter (fun x-> not ( List.exists (fun i->i=x) ls))



let start1 =[[A]]



let rec work2 (start,pathmaps)=
    let once =
        List.collect (fun (ls)->
        let firstList = ls//List.head start
        let ways = findway firstList
        match ways with
        |[] -> []
        |_->
            let ends = List.map (fun x ->x::ls) ways
            ends
        ) start
    let map1 = pathmaps
    let Mapme = once|> List.fold (fun (acc:Map<(Loc*Loc),int>) (ls:Loc list)->
                let k=A,ls.Head
                let v= path_cdis ls
                match (Map.tryFind k acc) with
                    |Some n-> 
                        if v< n then
                            Map.add k v acc
                        else
                            acc
                    |_->Map.add k v acc
                ) map1  //
    //Mapme|>printf "Map me %A"
        


    List.filter (fun x-> match x with
                |D::tail ->
                    printfn "Find the way %A = %d" x (path_cdis x)
                    false
                |_->true
                ) once |>printfn "%A"
    //裁剪路径
    let once3 = List.filter (fun (ls:Loc list)->
                let k=A,ls.Head
                let v= path_cdis ls
                match (Map.tryFind k Mapme) with
                    |Some n-> 
                        if v <= n then
                            true
                        else
                            false
                    |_->true
                ) once
                |>  List.filter (fun (x:Loc list)-> not (D = x.Head)) 
    //once3 |> printfn ">>>>Left is %A"
    once3,Mapme

let rec work1 (start,map) =
    match start with
    |[] ->()
    |_->
        let data = work2 (start,map)
        work1 data

work1 (start1,path_Dis_map) |> printfn ">>>%A"

[<EntryPoint>]
let main argv =
    printfn "%A" argv
    0 // return an integer exit code